| 
					
				 | 
			
			
				@ -335,6 +335,129 @@ public class DataInputService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 上传数据(三诺体征数据) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param json 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String inputBodySignsDataForSanruo(String json) throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put("upload_time",DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isEmpty(json)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","parameter json is null"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String fileName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String fileAbsPath = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String rowkey = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //提取json某些项值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DataBodySignsDO dataBodySignsDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dataBodySignsDO  = JSONObject.parseObject(json,DataBodySignsDO.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.error("json parse error,invalid json string"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","json parse error,invalid json string"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = JSONObject.parseObject(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String accessToken= dataBodySignsDO.getAccess_token(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String dataSource = dataBodySignsDO.getData_source(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String deviceSn = dataBodySignsDO.getSn(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String extCode = dataBodySignsDO.getExt_code(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //包含居民身份的数据,对设备数据进行校验绑定,此处包含的信息只有身份证号和用户名以及设备序列号,如果设备库中存在该序号的设备,则对绑定居民进行修改,改为当前居民,如果没有则跳过 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*if(jsonObject.containsKey("idcard") && jsonObject.containsKey("username")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String idcard = jsonObject.getString("idcard"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String username = jsonObject.getString("username"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            updateBindUser(dataSource,deviceSn,idcard,username); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = jsonObject.getJSONArray("data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null == jsonArray || jsonArray.size() == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","parameter 'data' of json no exist"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> rowkeyList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Map<String,String>>> familyList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //循环数据,一组数据存一行,生成一个rowkey,并将该rowkey存到es中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(Object obj:jsonArray){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject data = (JSONObject)obj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("del","1"); //添加删除标记 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String measuretime = jsonObject.getString("measure_time"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(null == measuretime){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    measuretime = DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //生成一份json数据的rowkey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rowkey = RowKeyUtils.makeRowKey(accessToken,dataSource, extCode, DateUtil.dateTimeParse(measuretime).getTime()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("rid",rowkey);//hbase的rowkey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                rowkeyList.add(rowkey); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.error("make rowkey error"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.put("msg","make rowkey error"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return result.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //组装B列 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, Map<String, String>> family = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, String> columnsB = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for(String key:data.keySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(StringUtils.equalsIgnoreCase("rid",key)){ //存到hbase里的数据不需要rid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                columnsB.put(key,data.getString(key)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(data.containsKey("ecg")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fileName = data.getString("fileName"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                fileAbsPath = data.getString("filepath"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            family.put(ConstantUtils.familyB,columnsB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            familyList.add(family); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<String> saveList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        saveList.add(jsonObject.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //将数据存入es 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean success = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            success = elasticSearchHelper.save(ConstantUtils.esIndex, ConstantUtils.esType, saveList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.error("upload signBodyData to elasticsearch failed," + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("msg","upload signBodyData to elasticsearch failed," + e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(success){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dataProcessLogService.saveLog(fileName, fileAbsPath, dataSource, "", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss), "1", "4", "com.yihu.iot.datainput.service.DataInputService.uploadData", DataOperationTypeEnum.upload1.getName(), 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray rids = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            rids.addAll(rowkeyList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("rid",rids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.SUCCESS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("response",ConstantUtils.FAIL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /*try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            boolean tableExists = hBaseAdmin.isTableExists(ConstantUtils.tableName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!tableExists) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                hBaseAdmin.createTable(ConstantUtils.tableName,ConstantUtils.familyB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hBaseHelper.addBulk(ConstantUtils.tableName, rowkeyList, familyList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //保存日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            dataProcessLogService.saveLog(fileName, fileAbsPath, dataSource, "", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss), "1", "3", "com.yihu.iot.datainput.service.DataInputService.uploadData", DataOperationTypeEnum.upload1.getName(), 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return "fail"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //保存日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result.toJSONString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 上传微信运动数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 目前只上传到es,hbase没有可用服务器 
			 |