| 
					
				 | 
			
			
				@ -4,14 +4,18 @@ import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.iot.datainput.service.DataInputService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.iot.service.common.MyJdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.mysql.query.BaseJpaService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.LinkedHashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -31,6 +35,76 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String accessToken = "yituoHouse"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ObjectMapper objectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private MyJdbcTemplate myJdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private JdbcTemplate jdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 初始化把奕拓小屋数据存入es 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void initIntoEs(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String id = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlM = "SELECT * FROM wlyy_iot_m WHERE id >? and create_time is not null ORDER BY id limit 2"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlD = "SELECT * from wlyy_iot_d WHERE mid = ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<WlyyIotM> list = jdbcTemplate.query(sqlM, new Object[] {id}, new BeanPropertyRowMapper<>(WlyyIotM.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        while (list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.forEach(wlyyIotM->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                List<WlyyIotD> wlyyIotDList = jdbcTemplate.query(sqlD, new Object[] {wlyyIotM.getId()}, new BeanPropertyRowMapper<>(WlyyIotD.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("sn", wlyyIotM.getSn()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONObject ext_code = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ext_code.put("UnitNo",wlyyIotM.getUnitNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ext_code.put("UnitName",wlyyIotM.getUnitName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ext_code.put("DoctorId",wlyyIotM.getDoctorId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ext_code.put("DoctorName",wlyyIotM.getDoctorName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ext_code.put("RecordNo",wlyyIotM.getRecordNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ext_code.put("MacAddr",wlyyIotM.getMacAddr()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("ext_code",ext_code.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("device_name",wlyyIotM.getDeviceName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("device_model",wlyyIotM.getDeviceModel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("idcard",wlyyIotM.getIdCardNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("username",wlyyIotM.getUserName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("access_token",accessToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                json.put("data_source",dataSource); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Map<String,Object>> map2 = new HashMap<String, Map<String, Object>>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for(WlyyIotD iotD:wlyyIotDList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String value =  "EcgData".equals(iotD.getCode())?iotD.getContent():iotD.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(map2.containsKey(iotD.getType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map2.get(iotD.getType()).put(iotD.getCode(),iotD.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Map<String,Object> map = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map.put(iotD.getCode(),iotD.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        map2.put(iotD.getType(),map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map.Entry entry : map2.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String code = entry.getKey().toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map<String,Object> valueMap = (HashMap)entry.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject js = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("measure_time",wlyyIotM.getMeasureTime());//测量时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("del",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("status","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("type",code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    analyzerMap(valueMap,js,code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    jsonArray.add(js); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("data",jsonArray); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dataInputService.inputBodySignsData(json.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info("初始化把奕拓小屋数据存入es,导入"+list.size()+"条,初始id:"+id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            id = list.get(list.size()-1).getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list = jdbcTemplate.query(sqlM, new Object[] {id}, new BeanPropertyRowMapper<>(WlyyIotM.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 针对上传的体数据进行基础数据的解析,进行主表数据的存储 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -118,7 +192,7 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    LinkedHashMap valueMap = (LinkedHashMap)entry.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject js = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("measure_time",code);//测量时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("measure_time",wlyyIotM.getMeasureTime());//测量时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("del",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("status","0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    js.put("type",code); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -140,7 +214,7 @@ public class IotAnalyzerService extends BaseJpaService<WlyyIotD, WlyyIotDDao> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return o == null?"":o.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void analyzerMap(Map<String,Object> mapInfo,JSONObject js,String type)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void analyzerMap(Map<String,Object> mapInfo,JSONObject js,String type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for(Object o: mapInfo.values()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String value = o == null?"":o.toString(); 
			 |