| 
					
				 | 
			
			
				@ -0,0 +1,470 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.figure.service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.figure.dao.HealthIndexDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.figure.model.HealthIndex; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.figure.util.IdCardUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Component; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import javax.transaction.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.DecimalFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 随访服务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * @author ysj add 2017-03-06 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Component 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Transactional(rollbackOn = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class HealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private JdbcTemplate jdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private HealthIndexDao healthIndexDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DecimalFormat df = new DecimalFormat("#.0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 自动生成居民一年的体征数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void autoHealthIndex(String patient,String type) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select code,idcard,ssc  from wlyy_patient_info where code = '"+patient+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String,Object> map = list.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String idcard = map.get("idcard").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int age = IdCardUtil.getAgeForIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String sex = IdCardUtil.getSexForIdcard(idcard);//1女 2男 3未知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 健康指标类型(1血糖,2血压,3体重,4腰围) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<HealthIndex> patientHealthIndexList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isEmpty(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                xuetang(patient,null,idcard,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                xueya(patient,null,idcard,age,sex,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                weight(patient,null,idcard,age,sex,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                yaowei(patient,null,idcard,age,sex,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if("1".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                xuetang(patient,null,idcard,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if("2".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                xueya(patient,null,idcard,age,sex,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if("3".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                weight(patient,null,idcard,age,sex,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if("4".equals(type)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                yaowei(patient,null,idcard,age,sex,patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            System.out.println(patientHealthIndexList.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndexDao.save(patientHealthIndexList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 血糖 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param deviceSn 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param idcard 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<HealthIndex> xuetang(String patient, String deviceSn, String idcard, List<HealthIndex> list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Calendar cal = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String fasting = "07:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String afterBreakfast = "09:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String beforeLunch = "11:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String afterLunch = "13:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String beforeDinner = "17:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String afterDinner = "19:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String beforeSleep = "23:00:00"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double value1,value2,value3,value4,value5,value6,value7; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //value2 1空腹血糖 2早餐后血糖 3午餐前血糖 4午餐后血糖 5晚餐前血糖 6晚餐后血糖 7睡前血糖 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //≥7.0 mmol/l或餐后血糖≥11.1 mmol/l 属于糖尿病 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex1 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex2 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex3 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex4 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex5 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex6 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex7 = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double high = 11.1,normal=7.0,low = 4.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int high1=0,normal1=0,low1=0,high2=0,normal2=0,low2=0,high3=0,normal3=0,low3=0;//1为近一个月,2为近半年,3为近一年 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i = 0;i<365;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value1 = 6.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value2 = 10.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value3 = 6.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value4 = 10.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value5 = 6.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value6 = 10.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value7 = 6.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1 = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2 = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3 = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4 = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5 = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6 = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7 = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Date recordDate = cal.getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 += random3ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 -= random2ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setValue1(df.format(value1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex1.setValue2("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 += random3ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 -= random2ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setValue1(df.format(value2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex2.setValue2("2"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value3 += random3ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value3 -= random2ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setValue1(df.format(value3)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex3.setValue2("3"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value4 += random3ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value4 -= random2ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setValue1(df.format(value4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex4.setValue2("4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value5 += random3ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value5 -= random2ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setValue1(df.format(value5)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex5.setValue2("5"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value6 += random3ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value6 -= random2ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setValue1(df.format(value6)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex6.setValue2("6"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //加 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value7 += random3ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value7 -= random2ten(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setValue1(df.format(value7)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex7.setValue2("7"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //统计数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex7); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            cal.add(Calendar.DAY_OF_YEAR,-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 血压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param deviceSn 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param idcard 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<HealthIndex> xueya(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Calendar cal = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int value1,value2,value3,value4,intValue1,intValue2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //140/90mmHg至160/95mmHg之间,不能确定为高血压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //成年人收缩压90-139.舒张压60-89为正常 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        age = age>65?65:age; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("2".equals(sex)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            intValue1 = 82+age; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                intValue2 = 84+random.nextInt(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                intValue2 = 84-random.nextInt(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            intValue1 = 80+age; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(random.nextInt(2)==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                intValue2 = 81+random.nextInt(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                intValue2 = 81-random.nextInt(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i = 0;i<365;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value1 = intValue1;//收缩压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value2 = intValue2;//舒张压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Date recordDate = cal.getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int temp = random.nextInt(10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(temp<5){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 += random.nextInt(21); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 += random.nextInt(6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if(temp>7){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 += 40+ random.nextInt(10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 += 15 + random.nextInt(5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 += 20+ random.nextInt(21); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 += 10 + random.nextInt(6); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value3 = random.nextInt(2)==1?(value2+random.nextInt(9)):(value2-random.nextInt(9));//心率 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value4 = random.nextInt(10)>8?1:0;//心率是否不齐 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setValue1(String.valueOf(value1)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setValue2(String.valueOf(value2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setValue3(String.valueOf(value3)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setValue4(String.valueOf(value4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            cal.add(Calendar.DAY_OF_YEAR,-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 体重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param deviceSn 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param idcard 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<HealthIndex> weight(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Calendar cal = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        cal.set(Calendar.HOUR_OF_DAY,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        cal.set(Calendar.MINUTE,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        cal.set(Calendar.SECOND,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double weiht = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(age<=19){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?55.4:49.2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(age>=20&&age<=24){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?57.3:50.8; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(age>=25&&age<=29){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?58.4:52.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(age>=30&&age<=34){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?59.8:53.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(age>=35&&age<=39){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?61.0:54.1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(age>=40&&age<=44){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?62.6:55.5; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(age>=45&&age<=49){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?63.1:56.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(age>=50&&age<=60){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?63.1:56.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            weiht = "2".equals(sex)?60.4:55.1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double weight = weiht; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int top = random.nextInt(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i = 0;i<52;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Date recordDate = cal.getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(top==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                weiht += 0.1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if(top==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(i<26){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht += randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht -= randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if(top==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(i<13){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht += randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(i<26){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht -= randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(i<39){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht += randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht -= randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else if(top==3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(i<10){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht += randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(i<20){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht -= randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(i<32){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht += randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else if(i<44){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht -= randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    weiht += randomTen(random); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setType(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setValue1(df.format(weiht)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            cal.add(Calendar.DAY_OF_YEAR,-7); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public double randomTen(Random random){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i = random.nextInt(5); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return i==0?0:i/10.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public double random2ten(Random random){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i = random.nextInt(20); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return i==0?0:i/10.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public double random3ten(Random random){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int i = random.nextInt(30); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return i==0?0:i/10.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static void main(String[] args) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        int in = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i = 0;i<20;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            in += random.nextInt(10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            System.out.println(in); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 腰围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param deviceSn 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param idcard 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<HealthIndex> yaowei(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Calendar cal = Calendar.getInstance(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        cal.set(Calendar.HOUR_OF_DAY,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        cal.set(Calendar.MINUTE,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        cal.set(Calendar.SECOND,0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double yaowei = "2".equals(sex)?86:78; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HealthIndex healthIndex = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (int i = 0;i<52;i++){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex = new HealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Date recordDate = cal.getTime(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            int j = random.nextInt(7); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(j==0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                yaowei = j%2==0?yaowei+0.3:yaowei-0.3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setIdcard(idcard); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setRecordDate(recordDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setType(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            healthIndex.setValue1(df.format(yaowei)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list.add(healthIndex); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            cal.add(Calendar.DAY_OF_YEAR,-7); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |