| 
					
				 | 
			
			
				@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.base.es.config.ElastricSearchHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.base.es.config.model.SaveModel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.base.hbase.HBaseAdmin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.base.hbase.HBaseHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.iot.datainput.enums.DataOperationTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.iot.datainput.util.RowKeyUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -40,6 +41,9 @@ public class DataInputService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HBaseHelper hBaseHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HBaseAdmin hBaseAdmin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String esIndex = "body_health_data"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String esType = "signs_data"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -49,13 +53,14 @@ public class DataInputService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 居民设备注册及绑定 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String bindUser(String json){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<IotDeviceDO> deviceDOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject jsonObject = JSONObject.parseObject(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String data_source = jsonObject.getString("data_source"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<IotDeviceDO> deviceDOList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = jsonObject.getJSONArray("data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(null != jsonArray){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -68,7 +73,7 @@ public class DataInputService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        continue; //表示设备已经绑定过 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    iotDeviceDO.setDeviceSn(sn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    iotDeviceDO.setCode(dataJson.getString("ext_code")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    iotDeviceDO.setCode(dataJson.getString("ext_code")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    iotDeviceDO.setName(dataJson.getString("device_name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    iotDeviceDO.setDeviceModel(dataJson.getString("device_model")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    iotDeviceDO.setDeviceSource("2"); //设备来源为居民绑定 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -90,7 +95,6 @@ public class DataInputService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                iotDeviceService.bindUser(deviceDOList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //保存日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                dataProcessLogService.saveLog("","",data_source,"", DateUtils.formatDate(new Date(), DateUtil.yyyy_MM_dd_HH_mm_ss),"1","4","com.yihu.iot.datainput.service.DataInputService.bindUser",DataOperationTypeEnum.bindUser.getName(),0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.error("注册绑定失败"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -109,6 +113,12 @@ public class DataInputService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(null != iotDeviceDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceDO.setUpdateUser(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceDO.setUpdateUserName(username); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceDO = new IotDeviceDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceDO.setDeviceSource(data_source); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceDO.setDeviceSn(deviveSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceDO.setCreateUser(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceDO.setCreateUserName(username); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        iotDeviceService.save(iotDeviceDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //保存日志 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -180,16 +190,20 @@ public class DataInputService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				               fileAbsPath = data.getString("filepath"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				           } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        family.put(familyB,columnsB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        family.put(familyB, columnsB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hBaseHelper.add(tableName,rowkey,family); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            boolean tableExists = hBaseAdmin.isTableExists(tableName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!tableExists) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                hBaseAdmin.createTable(tableName,familyA,familyB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            hBaseHelper.add(tableName, rowkey, family); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //保存日志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "success"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 |