| 
					
				 | 
			
			
				@ -9,6 +9,7 @@ import com.yihu.jw.care.util.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.util.DeviceLostMessageUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.Device; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DevicePatientDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.hospital.message.dao.SystemMessageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.GpsUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.http.HttpClientUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -52,6 +53,8 @@ public class PatientDeviceService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private JdbcTemplate jdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DeviceLostMessageUtil deviceLostMessageUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private SystemMessageDao systemMessageDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    Map<Integer, String> relations = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PostConstruct 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -246,7 +249,7 @@ public class PatientDeviceService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> lostSN = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> onContact = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*******************未失联**/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/*            //血糖仪,血压计。30天内有数据上传,则改为未失联 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           //血糖仪,血压计。30天内有数据上传,则改为未失联 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and EXISTS ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') "; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -263,13 +266,13 @@ public class PatientDeviceService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            devices = jdbcTemplate.queryForList(sql,String.class) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (devices.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                onContact.addAll(devices); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /***************失联**/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //血糖仪、血压**/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            devices = jdbcTemplate.queryForList(sql,String.class) ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (devices.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lostSN.addAll(devices); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -282,7 +285,10 @@ public class PatientDeviceService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lostSN.addAll(devices); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (onContact.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyDeviceDao.updateByContactStatus(1,new Date(),onContact); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                wlyyDeviceDao.updateByContactStatus(1,new Date(),onContact); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //如果在线 将之前的离线消息全部清除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                systemMessageDao.delMessageByRelationCode(onContact); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (lostSN.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                wlyyDeviceDao.updateByContactStatus(0,new Date(),lostSN); 
			 |