| 
					
				 | 
			
			
				@ -1,305 +0,0 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.iot.datainput.controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.iot.datainput.dao.IotDeviceBaiyiDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.iot.datainput.service.DataInputService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.iot.device.IotDeviceBaiyiDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.http.MediaType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.LinkedHashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * @author cws on 2018/1/16. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RequestMapping("svr-iot-sn/analyze" ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Api(tags = "设备数据解析入库", description = "三诺设备的采集数据上传,并同步到I健康。") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class IotAnalyzerController extends EnvelopRestEndpoint { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private Logger logger = LoggerFactory.getLogger(DataInputService.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DataInputService dataInputService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    ObjectMapper objectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private IotDeviceBaiyiDao iotDeviceBaiyiDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 基于奕拓小屋上传的体征数据,进行解析入库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param jsonData 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PostMapping(value = "/sannuo" ,consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "三诺血糖仪数据解析入库(单条)", notes = "三诺体征数据解析入库") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String updateSanruoDate( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "json_data", value = "Json数据", required = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestBody String jsonData) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Envelop envelop = new Envelop(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String str = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String strResult = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String accessToken  = "sannuo"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map res = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map info = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //JSON数据解析 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map dataDetail = objectMapper.readValue(jsonData, HashMap.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject params = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            LinkedHashMap msgdataMap = (LinkedHashMap)dataDetail.get("msgdata"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(msgdataMap != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                info = msgdataMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                info = dataDetail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 增加判断,当测量值小于1时,定义为异常值,不进行数据的存储。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(Double.parseDouble(info.get("result").toString()) < 1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("statusCode", "00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("desc", info.get("devicesn") + "体征数据异常(小于正常值)。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("data",info.get("result") == null? "":info.get("result").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("code",info.get("code") == null? "":info.get("code").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("deviceSn",info.get("devicesn") == null? "":info.get("devicesn").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("userCode",info.get("usercode") == null? "":info.get("usercode").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("openId",info.get("openid") == null? "":info.get("openid").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("unit",info.get("unit") == null? "":info.get("unit").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("sendTime",info.get("testtime") == null? "":info.get("testtime").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //血糖测试时间段标志位(0餐前 1餐后 2随机) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("foodStatus",info.get("foodstatus") == null? "":info.get("foodstatus").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("deviceType",2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("manufacturerCode","threeNod"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("manufacturerName","三诺设备"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("uploadTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("button","1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("state",0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            jsonArray.add(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("data", jsonArray); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("accessToken","threeNod"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("measure_time",info.get("testtime") == null? "":info.get("testtime").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            params.put("sn",info.get("devicesn") == null? "":info.get("devicesn").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //体征信息上传成功后,同步到厦门I健康 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.put("id",""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            boolean synFlag = dataInputService.synXMIjk(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(synFlag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("statusCode", "00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("desc", info.get("devicesn") + "体征信息上传厦门I健康成功。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("statusCode", "02"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("desc", info.get("devicesn") +  "体征信息上传厦门I健康失败。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            strResult = objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.info(strResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            /*str = dataInputService.inputBodySignsData(params.toString(),accessToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject result = JSONObject.parseObject(str); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.endsWithIgnoreCase(ConstantUtils.FAIL,result.getString("response"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map res = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("statusCode", "03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("desc", result.getString("msg")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("deviceSn", info.get("devicesn") == null? "":info.get("devicesn").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                strResult = objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map res = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("statusCode", "00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                JSONArray ridRes = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                ridRes = (JSONArray) result.get("rid"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String rid = ridRes.get(0).toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("rid", rid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                res.put("deviceSn", info.get("devicesn") == null? "":info.get("devicesn").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //体征信息上传成功后,同步到厦门I健康 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("id",rid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                boolean synFlag = dataInputService.synXMIjk(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(synFlag){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res.put("desc", "体征信息上传成功,同步到厦门I健康成功。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res.put("statusCode", "03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    res.put("desc", "体征信息上传成功,同步到厦门I健康失败。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                strResult = objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                logger.info(strResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return strResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("statusCode", "03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("desc", "服务异常,体征信息上传失败。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            strResult = objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.error(strResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return strResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PostMapping(value = "/heartRate") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "柏颐心率数据接收", notes = "柏颐心率数据接收") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String heartRate( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "imei", value = "15位设备唯一序号") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "imei",required = false)String imei, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "time_begin",required = false)String time_begin, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "heartrate", value = "心率") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "heartrate",required = false)int heartrate, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "theshold_heartrate_h", value = "心率阈值上限") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "theshold_heartrate_h",required = false)int theshold_heartrate_h, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "theshold_heartrate_l", value = "心率阈值下限") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "theshold_heartrate_l",required = false)int theshold_heartrate_l) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String strResult = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map res = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String info  = "imei="+imei+";time_begin="+time_begin+";heartrate="+heartrate+";theshold_heartrate_h="+theshold_heartrate_h+";theshold_heartrate_l="+theshold_heartrate_l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("info="+info); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            IotDeviceBaiyiDO iotDeviceBaiyiDO=new IotDeviceBaiyiDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setImei(imei); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setTimeBegin(time_begin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setValue1(heartrate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setValue2(theshold_heartrate_h); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setValue3(theshold_heartrate_l); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDao.save(iotDeviceBaiyiDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return BaiyiDataParam(iotDeviceBaiyiDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("statusCode", "03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("desc", "服务异常,体征信息上传失败。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            strResult = objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.error(strResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return strResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PostMapping(value = "/bloodPressure") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "柏颐血压数据接收", notes = "柏颐血压数据接收") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String bloodPressure( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "imei", value = "15位设备唯一序号", required = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "imei",required = false)String imei, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "time_begin", value = "发生时间YYYY-MM-DD HH:mm:SS", required = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "time_begin",required = false)String time_begin, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "dbp", value = "舒张压", required = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "dbp",required = false)int dbp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "dbp_l", value = "舒张压报警下限", required = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "dbp_l",required = false)int dbp_l, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "sbp", value = "收缩压", required = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "sbp",required = false)int sbp, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "sbp_h", value = "收缩压报警上限", required = true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "sbp_h",required = false)int sbp_h) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String strResult = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map res = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String info= "imei="+imei+";time_begin="+time_begin+";dbp="+dbp+";dbp_l="+dbp_l+";sbp="+sbp+";sbp_h="+sbp_h; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info("info="+info); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            IotDeviceBaiyiDO iotDeviceBaiyiDO=new IotDeviceBaiyiDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setImei(imei); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setTimeBegin(time_begin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setValue1(dbp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setValue2(dbp_l); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setValue3(sbp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDO.setValue4(sbp_h); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceBaiyiDao.save(iotDeviceBaiyiDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return BaiyiDataParam(iotDeviceBaiyiDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("statusCode", "03"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("desc", "服务异常,体征信息上传失败。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            strResult = objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            logger.error(strResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return strResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 封装数据上传至i健康 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param iotDeviceBaiyiDO 设备数据实体 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String BaiyiDataParam(IotDeviceBaiyiDO iotDeviceBaiyiDO)throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONArray jsonArray = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject params = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject data = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map res = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 增加判断,当测量值小于1时,定义为异常值,不进行数据的存储。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (iotDeviceBaiyiDO.getValue1() < 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("statusCode", "00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("desc", iotDeviceBaiyiDO.getImei() + "体征数据异常(小于正常值)。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (2 == iotDeviceBaiyiDO.getType()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //血压测量数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("data", iotDeviceBaiyiDO.getValue3() + "," + iotDeviceBaiyiDO.getValue1()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //单位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("unit", "mmHg"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //心率测量数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("data", iotDeviceBaiyiDO.getValue1()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //单位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.put("unit", "bpm"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //按键号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("button", "-1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备唯一码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("deviceSn", iotDeviceBaiyiDO.getImei()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //设备类型1:血压 5:心率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("deviceType", "4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("measurementType",iotDeviceBaiyiDO.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //厂商代码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("manufacturerCode", "baiyi"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //厂商名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("manufacturerName", "柏颐设备"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //发送时间yyyy-MM-dd HH:mm:ss 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("sendTime", iotDeviceBaiyiDO.getTimeBegin()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("state", 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //单位mmol/L,mmHg 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("unit", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //体征上传时间yyyy-MM-dd HH:mm:ss 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("uploadTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        jsonArray.add(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        params.put("data", jsonArray); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //体征信息上传成功后,同步到厦门I健康 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        data.put("id", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean synFlag = dataInputService.synXMIjk(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (synFlag) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("statusCode", "00"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("desc", iotDeviceBaiyiDO.getImei() + "体征信息上传厦门I健康成功。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("statusCode", "02"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            res.put("desc", iotDeviceBaiyiDO.getImei() + "体征信息上传厦门I健康失败。"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String strResult = objectMapper.writeValueAsString(res); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        logger.info(strResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return strResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//      return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |