| 
					
				 | 
			
			
				@ -218,56 +218,72 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public MixEnvelop<IotDeviceVO, IotDeviceVO> queryPage(String sn, String hospital, String hospitalName,String orderId, String purcharseId, String productId, String name, String categoryCode, String manufacturerId, Integer page, Integer size) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String filters = "del=1;"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String semicolon = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sql = new StringBuffer("SELECT DISTINCT c.* from iot_device c  WHERE c.del=1 "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        StringBuffer sqlCount = new StringBuffer("SELECT COUNT(DISTINCT c.id) count from iot_device c  WHERE c.del=1 "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Object> args = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(orderId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon +"orderId="+orderId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.order_id = ? "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.order_id = '").append(orderId).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(purcharseId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon +"purchaseId="+purcharseId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.purchase_id = ? "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.purchase_id = '").append(purcharseId).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(purcharseId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(hospital)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon +"hospital="+hospital; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.hospital = ? "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.hospital = '").append(hospital).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(hospital); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(sn)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon + "deviceSn?"+sn+" g1;simNo?" + sn + " g1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sn = "%"+sn+"%"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and (c.device_sn like ? or c.sim_no like ?)"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and (c.device_sn like '").append(sn).append("' or c.sim_no like '").append(sn).append("')"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(sn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(sn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(productId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon +"productId="+productId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.product_id = ? "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.product_id = '").append(productId).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(productId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(name)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon + "name?"+name+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            name = "%"+name+"%"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.name like ?"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.name like '").append(name).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(categoryCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon +"categoryCode="+categoryCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.category_code = ? "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.category_code = '").append(categoryCode).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(categoryCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(manufacturerId)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon +"manufacturerId="+manufacturerId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.manufacturer_id = ? "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.manufacturer_id = '").append(manufacturerId).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(manufacturerId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isNotBlank(hospitalName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters += semicolon + "hospitalName?"+hospitalName+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hospitalName = "%"+hospitalName+"%"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.hospital_name like ?"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.hospital_name like '").append(hospitalName).append("'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            args.add(hospitalName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //数据权限过滤 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> orgList = orgUserService.getUserOrgById(userAgent.getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(!orgList.contains(userAgent.commonHospital)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters +=  semicolon +" hospital ="+orgUserService.getUserOrg2(orgList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            semicolon = ";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql.append(" and c.hospital in (").append(orgUserService.getUserOrg(orgList)).append(")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sqlCount.append(" and c.hospital in (").append(orgUserService.getUserOrg(orgList)).append(")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sorts = "-updateTime"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //得到list数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<IotDeviceDO> list = search(null, filters, sorts, page, size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //获取总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count = getCount(filters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql.append("order by c.update_time desc limit ").append((page-1)*size).append(",").append(size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<IotDeviceDO> list = jdbcTempalte.query(sql.toString(),args.toArray(),new BeanPropertyRowMapper(IotDeviceDO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> countList = jdbcTempalte.queryForList(sqlCount.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        long count = Long.valueOf(countList.get(0).get("count").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //DO转VO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<IotDeviceVO> iotDeviceVOList = convertToModels(list,new ArrayList<>(list.size()),IotDeviceVO.class); 
			 |