|  | @ -245,61 +245,56 @@ public class PatientDeviceService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String startTimeDevice2 =  DateUtil.getPreTime(endTime,-60*2+"");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             List<String> lostSN = new ArrayList<>();
 | 
	
		
			
				|  |  |             List<String> onContact = new ArrayList<>();
 | 
	
		
			
				|  |  |             /*******************未失联**/
 | 
	
		
			
				|  |  |            //血糖仪,血压计。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+"') ";
 | 
	
		
			
				|  |  | //            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  | //            if (devices.size() > 0) {
 | 
	
		
			
				|  |  | //                onContact.addAll(devices);
 | 
	
		
			
				|  |  | //            }
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //            //智能拐杖。手表2天内有数据上传,则改为未失联**
 | 
	
		
			
				|  |  | //            sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (4,16) and EXISTS ( " +
 | 
	
		
			
				|  |  | //                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
 | 
	
		
			
				|  |  | //                    " BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"') ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //清除消息
 | 
	
		
			
				|  |  |             String sql = " select distinct dp.device_sn from device_data_push_log dp where  dp.create_time " +
 | 
	
		
			
				|  |  |                     " BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' ";
 | 
	
		
			
				|  |  |             List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  |             if (devices.size() > 0) {
 | 
	
		
			
				|  |  |                 onContact.addAll(devices);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             /***************失联**/
 | 
	
		
			
				|  |  |             //血糖仪、血压**/
 | 
	
		
			
				|  |  |             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+"') ";
 | 
	
		
			
				|  |  |             devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  |             if (devices.size() > 0) {
 | 
	
		
			
				|  |  |                 lostSN.addAll(devices);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //智能拐杖、手表 睡眠带
 | 
	
		
			
				|  |  |             sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (4,13,16) 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 '"+startTimeDevice2+"' AND '"+endTime+"') ";
 | 
	
		
			
				|  |  |             devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  |             if (devices.size() > 0) {
 | 
	
		
			
				|  |  |                 lostSN.addAll(devices);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (onContact.size()>0){
 | 
	
		
			
				|  |  | //                wlyyDeviceDao.updateByContactStatus(1,new Date(),onContact);
 | 
	
		
			
				|  |  |                 //如果在线 将之前的离线消息全部清除
 | 
	
		
			
				|  |  |                 systemMessageDao.delMessageByRelationCode(onContact);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (lostSN.size()>0){
 | 
	
		
			
				|  |  |                 wlyyDeviceDao.updateByContactStatus(0,new Date(),lostSN);
 | 
	
		
			
				|  |  |                 deviceLostMessageUtil.deviceLostMessage(lostSN);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         List<String> lostSN = new ArrayList<>();
 | 
	
		
			
				|  |  |         List<String> onContact = new ArrayList<>();
 | 
	
		
			
				|  |  |         /*******************未失联**/
 | 
	
		
			
				|  |  |         //血糖仪,血压计。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+"') ";
 | 
	
		
			
				|  |  | //        List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  | //        if (devices.size() > 0) {
 | 
	
		
			
				|  |  | //            onContact.addAll(devices);
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //        //智能拐杖。手表2天内有数据上传,则改为未失联**
 | 
	
		
			
				|  |  | //        sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (4,16) and EXISTS ( " +
 | 
	
		
			
				|  |  | //                "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
 | 
	
		
			
				|  |  | //                " BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"') ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             logger.info(e.getMessage());
 | 
	
		
			
				|  |  |         //清除消息
 | 
	
		
			
				|  |  |         String sql = " select distinct dp.device_sn from device_data_push_log dp where  dp.create_time " +
 | 
	
		
			
				|  |  |                 " BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' and dp.device_sn is not null ";
 | 
	
		
			
				|  |  |         List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  |         if (devices.size() > 0) {
 | 
	
		
			
				|  |  |             onContact.addAll(devices);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         /***************失联**/
 | 
	
		
			
				|  |  |         //血糖仪、血压**/
 | 
	
		
			
				|  |  |         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.device_sn is not null and dp.create_time " +
 | 
	
		
			
				|  |  |                 " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
 | 
	
		
			
				|  |  |         devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  |         if (devices.size() > 0) {
 | 
	
		
			
				|  |  |             lostSN.addAll(devices);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //智能拐杖、手表 睡眠带
 | 
	
		
			
				|  |  |         sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (4,13,16) and not EXISTS ( " +
 | 
	
		
			
				|  |  |                 "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.device_sn is not null and dp.create_time " +
 | 
	
		
			
				|  |  |                 " BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"') ";
 | 
	
		
			
				|  |  |         devices = jdbcTemplate.queryForList(sql,String.class) ;
 | 
	
		
			
				|  |  |         if (devices.size() > 0) {
 | 
	
		
			
				|  |  |             lostSN.addAll(devices);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (onContact.size()>0){
 | 
	
		
			
				|  |  | //            wlyyDeviceDao.updateByContactStatus(1,new Date(),onContact);
 | 
	
		
			
				|  |  |             //如果在线 将之前的离线消息全部清除
 | 
	
		
			
				|  |  |             systemMessageDao.delMessageByRelationCode(onContact);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (lostSN.size()>0){
 | 
	
		
			
				|  |  |             wlyyDeviceDao.updateByContactStatus(0,new Date(),lostSN);
 | 
	
		
			
				|  |  |             deviceLostMessageUtil.deviceLostMessage(lostSN);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 |