| 
					
				 | 
			
			
				@ -472,6 +472,24 @@ public class DeviceService extends BaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                userType = "-1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            PatientDevice patientDevice = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn,type,userType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int dataUoloadCount = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (patientDevice!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String today = DateUtil.getStringDateShort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String startTime = today+" 00:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String endTime = today+" 23:59:59"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                int dateType =1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (deviceType==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    dateType=2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if (deviceType==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    dateType=1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String countSql = "SELECT count(*) num FROM device.wlyy_patient_health_index where `user`='"+patientDevice.getUser()+"' and type = "+dateType+" AND record_date >"+startTime+" and record_date <= "+endTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> countMap = jdbcTemplate.queryForMap(countSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                dataUoloadCount = Integer.valueOf(String.valueOf(countMap.get("num"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new Exception("This device is not relate patient!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            PatientHealthIndex result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (result == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new Exception("This device is not relate patient!"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -481,22 +499,23 @@ public class DeviceService extends BaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Patient patient = patientDao.findByCode(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //增加积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String sql = "select count(*) num from wlyy.wlyy_devices where device_code = '"+deviceSn+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String url = wlyyService + "healthBank/insertCredits"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<NameValuePair> params = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    params.add(new BasicNameValuePair("creditsDetail", "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\"MEASURE\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\"350205\"}")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String response = HttpClientUtil.post(url, params, "UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    System.out.println(response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String status = jsonObject.getString("status"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (!"200".equals(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.error(jsonObject.getString("msg")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (dataUoloadCount>0 && "350205".equals(patient.getTown())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String sql = "select count(*) num from device.wlyy_devices where device_code = '"+deviceSn+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    Map<String,Object> deviceCountMap = jdbcTemplate.queryForMap(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String url = wlyyService + "healthBank/insertCredits"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<NameValuePair> params = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        params.add(new BasicNameValuePair("creditsDetail", "{\"tradeType\":\"HEALTH_TASK\",\"flag\":\"MEASURE\",\"tradeDirection\":1,\"status\":1,\"patientId\":\""+result.getUser()+"\",\"hospital\":\"350205\"}")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String response = HttpClientUtil.post(url, params, "UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        System.out.println(response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String status = jsonObject.getString("status"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (!"200".equals(status)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            logger.error(jsonObject.getString("msg")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                /*if (Integer.valueOf(String.valueOf(deviceCountMap.get("num")))>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String url = wlyyService + "/healthBank/insertCredits"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    org.json.JSONObject params = new org.json.JSONObject(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -509,7 +528,9 @@ public class DeviceService extends BaseService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        logger.error(jsonObject.getString("msg")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //血糖、血压数据需校验,如果超标,需要发送消息给医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					            if (1 == deviceType || 2 == deviceType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						            verifyHealthIndex(result); 
			 |