Переглянути джерело

患者预约记录添加已取消的记录

yeshijie 8 роки тому
батько
коміт
5e1fe1328e

+ 2 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexDao.java

@ -16,4 +16,6 @@ public interface HealthIndexDao extends PagingAndSortingRepository<HealthIndex,
	@Query("select p from HealthIndex p where p.user = ?1")
	List<HealthIndex> findByUser(String user);
	@Query(value = "select * from wlyy_health_index where user=?1 and type =?2 and record_date between ?3 and ?4 order by record_date desc limit 0,1",nativeQuery = true)
	HealthIndex findByPatientAndType(String patient,String type,String startTime,String endTime);
}

+ 10 - 0
patient-co-figure/src/main/java/com/yihu/figure/dao/HealthIndexStatisticsDao.java

@ -0,0 +1,10 @@
package com.yihu.figure.dao;
import com.yihu.figure.model.HealthIndexStatistics;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/3/6.
 */
public interface HealthIndexStatisticsDao extends PagingAndSortingRepository<HealthIndexStatistics, Long> {
}

+ 114 - 0
patient-co-figure/src/main/java/com/yihu/figure/model/HealthIndexStatistics.java

@ -0,0 +1,114 @@
package com.yihu.figure.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康指标
 * @author ysj
 *
 */
@Entity
@Table(name = "wlyy_health_index_statistics")
public class HealthIndexStatistics extends IdEntity {
	// 患者标志
	private String user;
	// (血糖/血压)偏高(心率不齐)
	private Integer high;
	// (血糖/血压)正常(心率齐)
	private Integer normal;
	// (血糖/血压)偏低
	private Integer low;
	// 健康指标类型(1血糖,2血压)
	private Integer type;
	//测试类型(1空腹血糖 2早餐后血糖 3午餐前血糖 4午餐后血糖 5晚餐前血糖 6晚餐后血糖 7睡前血糖,8舒张压,9收缩压,10心率)
	private Integer bloodType;
	//时间类型
	private Integer timeType;
	// 添加时间
	private Date czrq;
	public HealthIndexStatistics() {
	}
	public HealthIndexStatistics(String user, Integer high, Integer normal, Integer low, Integer type, Integer bloodType, Integer timeType, Date czrq) {
		this.user = user;
		this.high = high;
		this.normal = normal;
		this.low = low;
		this.type = type;
		this.bloodType = bloodType;
		this.timeType = timeType;
		this.czrq = czrq;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}
	public Integer getHigh() {
		return high;
	}
	public void setHigh(Integer high) {
		this.high = high;
	}
	public Integer getNormal() {
		return normal;
	}
	public void setNormal(Integer normal) {
		this.normal = normal;
	}
	public Integer getLow() {
		return low;
	}
	public void setLow(Integer low) {
		this.low = low;
	}
	public Integer getBloodType() {
		return bloodType;
	}
	public void setBloodType(Integer bloodType) {
		this.bloodType = bloodType;
	}
	public Integer getTimeType() {
		return timeType;
	}
	public void setTimeType(Integer timeType) {
		this.timeType = timeType;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 346 - 8
patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexService.java

@ -1,9 +1,14 @@
package com.yihu.figure.service;
import com.yihu.figure.dao.HealthIndexDao;
import com.yihu.figure.dao.HealthIndexStatisticsDao;
import com.yihu.figure.model.HealthIndex;
import com.yihu.figure.model.HealthIndexStatistics;
import com.yihu.figure.util.DateUtil;
import com.yihu.figure.util.ETLConstantData;
import com.yihu.figure.util.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@ -13,7 +18,7 @@ import java.text.DecimalFormat;
import java.util.*;
/**
 * 随访服务
 * 居民体征
 *
 * @author ysj add 2017-03-06
 */
@ -25,9 +30,76 @@ public class HealthIndexService extends BaseService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HealthIndexDao healthIndexDao;
    @Autowired
    private HealthIndexStatisticsDao healthIndexStatisticsDao;
    private DecimalFormat df = new DecimalFormat("#.0");
    /**
     * 获取居民体征数据
     * @param patient
     * @param type
     * @return
     */
    public JSONObject healthIndex(String patient, String type, String bloodType, String timeType) throws Exception{
        JSONObject json = new JSONObject();
        int limit = 1;
        if("1".equals(timeType)){
            limit = 30;
        }else if("2".equals(timeType)){
            limit = 182;
        }else if("3".equals(timeType)){
            limit = 365;
        }
        String sql1 = "select date_format(record_date,'%Y-%c-%d %H:%i:%s') recordDate, ";
        if("1".equals(type)){
            //血糖
            sql1 += "value1 value  " +
                   "from wlyy_health_index " +
                   "where user = '"+patient+"' " +
                   "and type="+type+" " +
                   "and value2='"+bloodType+"' " +
                   "order by record_date desc " +
                   "limit "+limit;
        }else{
            //血压
            if("9".equals(bloodType)){
                sql1 +=" value1 value ";
            }else if("8".equals(bloodType)){
                sql1 +=" value2 value ";
            }else if("10".equals(bloodType)){
                sql1 +=" value3 value ";
            }
            sql1 += "from wlyy_health_index " +
                    "where user = '"+patient+"' " +
                    "and type="+type+" " +
                    "order by record_date desc " +
                    "limit "+limit;
        }
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql1);
        String sql2 = "select high,normal,low  " +
                "from wlyy_health_index_statistics " +
                "where user = '"+patient+"' " +
                "and time_type="+timeType+" " +
                "and blood_type='"+bloodType+"' " +
                "limit 1";
        List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
        Map<String,Object> map = null;
        if(list2.size()>0){
            map = list2.get(0);
        }else{
            map = new HashMap<>();
            map.put("high",0);
            map.put("normal",0);
            map.put("low",0);
        }
        json.put("healths",list1);
        json.put("statistics",map);
        return json;
    }
    /**
     * 自动生成居民一年的体征数据
     * @param patient
@ -70,6 +142,13 @@ public class HealthIndexService extends BaseService {
     * @param idcard
     */
    public List<HealthIndex> xuetang(String patient, String deviceSn, String idcard, List<HealthIndex> list){
        String startTime = DateUtil.getStringDateShort()+" 00:00:00";
        String endTime = DateUtil.getStringDateShort()+" 23:59:59";
        HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"1",startTime,endTime);
        if(healthIndex!=null){//判断是否已经生成过数据
            return list;
        }
        Calendar cal = Calendar.getInstance();
        String fasting = "07:00:00";
@ -91,9 +170,18 @@ public class HealthIndexService extends BaseService {
        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为近一年
        int month = 30;//一个月取30天
        int halfYear = 182;//半年取182天
        double high = 11.1,normal=7.0,low = 4.0;//(空腹4.0-7.0为正常,餐后7.0-11.0为正常)
        int high11=0,normal11=0,low11=0,high12=0,normal12=0,low12=0,high13=0,normal13=0,low13=0;//1为近一个月,2为近半年,3为近一年
        int high21=0,normal21=0,low21=0,high22=0,normal22=0,low22=0,high23=0,normal23=0,low23=0;//1为近一个月,2为近半年,3为近一年
        int high31=0,normal31=0,low31=0,high32=0,normal32=0,low32=0,high33=0,normal33=0,low33=0;//1为近一个月,2为近半年,3为近一年
        int high41=0,normal41=0,low41=0,high42=0,normal42=0,low42=0,high43=0,normal43=0,low43=0;//1为近一个月,2为近半年,3为近一年
        int high51=0,normal51=0,low51=0,high52=0,normal52=0,low52=0,high53=0,normal53=0,low53=0;//1为近一个月,2为近半年,3为近一年
        int high61=0,normal61=0,low61=0,high62=0,normal62=0,low62=0,high63=0,normal63=0,low63=0;//1为近一个月,2为近半年,3为近一年
        int high71=0,normal71=0,low71=0,high72=0,normal72=0,low72=0,high73=0,normal73=0,low73=0;//1为近一个月,2为近半年,3为近一年
        Random random = new Random();
        List<HealthIndexStatistics> statisticsList = new ArrayList<>();
        for (int i = 0;i<365;i++){
            value1 = 6.0;
            value2 = 10.0;
@ -231,7 +319,159 @@ public class HealthIndexService extends BaseService {
            healthIndex7.setValue2("7");
            //统计数据
            int flag1 = ETLConstantData.xueTangBefore(value1);
            int flag2 = ETLConstantData.xueTangAfter(value2);
            int flag3 = ETLConstantData.xueTangBefore(value3);
            int flag4 = ETLConstantData.xueTangAfter(value4);
            int flag5 = ETLConstantData.xueTangBefore(value5);
            int flag6 = ETLConstantData.xueTangAfter(value6);
            int flag7 = ETLConstantData.xueTangBefore(value7);
            if(flag1>0){
                high11 += i<month?1:0;
                high12 += i<halfYear?1:0;
                high13 ++;
            }else if(flag1<0){
                low11 += i<month?1:0;
                low12 += i<halfYear?1:0;
                low13 ++;
            }else {
                //正常
                normal11 += i<month?1:0;
                normal12 += i<halfYear?1:0;
                normal13 ++;
            }
            if(flag2>0){
                high21 += i<month?1:0;
                high22 += i<halfYear?1:0;
                high23 ++;
            }else if(flag2<0){
                low21 += i<month?1:0;
                low22 += i<halfYear?1:0;
                low23 ++;
            }else {
                //正常
                normal21 += i<month?1:0;
                normal22 += i<halfYear?1:0;
                normal23 ++;
            }
            if(flag3>0){
                high31 += i<month?1:0;
                high32 += i<halfYear?1:0;
                high33 ++;
            }else if(flag3<0){
                low31 += i<month?1:0;
                low32 += i<halfYear?1:0;
                low33 ++;
            }else {
                //正常
                normal31 += i<month?1:0;
                normal32 += i<halfYear?1:0;
                normal33 ++;
            }
            if(flag4>0){
                high41 += i<month?1:0;
                high42 += i<halfYear?1:0;
                high43 ++;
            }else if(flag4<0){
                low41 += i<month?1:0;
                low42 += i<halfYear?1:0;
                low43 ++;
            }else {
                //正常
                normal41 += i<month?1:0;
                normal42 += i<halfYear?1:0;
                normal43 ++;
            }
            if(flag5>0){
                high51 += i<month?1:0;
                high52 += i<halfYear?1:0;
                high53 ++;
            }else if(flag5<0){
                low51 += i<month?1:0;
                low52 += i<halfYear?1:0;
                low53 ++;
            }else {
                //正常
                normal51 += i<month?1:0;
                normal52 += i<halfYear?1:0;
                normal53 ++;
            }
            if(flag6>0){
                high61 += i<month?1:0;
                high62 += i<halfYear?1:0;
                high63 ++;
            }else if(flag6<0){
                low61 += i<month?1:0;
                low62 += i<halfYear?1:0;
                low63 ++;
            }else {
                //正常
                normal61 += i<month?1:0;
                normal62 += i<halfYear?1:0;
                normal63 ++;
            }
            if(flag7>0){
                high71 += i<month?1:0;
                high72 += i<halfYear?1:0;
                high73 ++;
            }else if(flag7<0){
                low71 += i<month?1:0;
                low72 += i<halfYear?1:0;
                low73 ++;
            }else {
                //正常
                normal71 += i<month?1:0;
                normal72 += i<halfYear?1:0;
                normal73 ++;
            }
            if(i==29){
                HealthIndexStatistics healthIndexStatistics1 = new HealthIndexStatistics(patient,high11,normal11,low11,1,1,1,new Date());
                HealthIndexStatistics healthIndexStatistics2 = new HealthIndexStatistics(patient,high21,normal21,low21,1,2,1,new Date());
                HealthIndexStatistics healthIndexStatistics3 = new HealthIndexStatistics(patient,high31,normal31,low31,1,3,1,new Date());
                HealthIndexStatistics healthIndexStatistics4 = new HealthIndexStatistics(patient,high41,normal41,low41,1,4,1,new Date());
                HealthIndexStatistics healthIndexStatistics5 = new HealthIndexStatistics(patient,high51,normal51,low51,1,5,1,new Date());
                HealthIndexStatistics healthIndexStatistics6 = new HealthIndexStatistics(patient,high61,normal61,low61,1,6,1,new Date());
                HealthIndexStatistics healthIndexStatistics7 = new HealthIndexStatistics(patient,high71,normal71,low71,1,7,1,new Date());
                statisticsList.add(healthIndexStatistics1);
                statisticsList.add(healthIndexStatistics2);
                statisticsList.add(healthIndexStatistics3);
                statisticsList.add(healthIndexStatistics4);
                statisticsList.add(healthIndexStatistics5);
                statisticsList.add(healthIndexStatistics6);
                statisticsList.add(healthIndexStatistics7);
            }
            if(i==181){
                HealthIndexStatistics healthIndexStatistics1 = new HealthIndexStatistics(patient,high12,normal12,low12,1,1,2,new Date());
                HealthIndexStatistics healthIndexStatistics2 = new HealthIndexStatistics(patient,high22,normal22,low22,1,2,2,new Date());
                HealthIndexStatistics healthIndexStatistics3 = new HealthIndexStatistics(patient,high32,normal32,low32,1,3,2,new Date());
                HealthIndexStatistics healthIndexStatistics4 = new HealthIndexStatistics(patient,high42,normal42,low42,1,4,2,new Date());
                HealthIndexStatistics healthIndexStatistics5 = new HealthIndexStatistics(patient,high52,normal52,low52,1,5,2,new Date());
                HealthIndexStatistics healthIndexStatistics6 = new HealthIndexStatistics(patient,high62,normal62,low62,1,6,2,new Date());
                HealthIndexStatistics healthIndexStatistics7 = new HealthIndexStatistics(patient,high72,normal72,low72,1,7,2,new Date());
                statisticsList.add(healthIndexStatistics1);
                statisticsList.add(healthIndexStatistics2);
                statisticsList.add(healthIndexStatistics3);
                statisticsList.add(healthIndexStatistics4);
                statisticsList.add(healthIndexStatistics5);
                statisticsList.add(healthIndexStatistics6);
                statisticsList.add(healthIndexStatistics7);
            }
            if(i==364){
                HealthIndexStatistics healthIndexStatistics1 = new HealthIndexStatistics(patient,high13,normal13,low13,1,1,3,new Date());
                HealthIndexStatistics healthIndexStatistics2 = new HealthIndexStatistics(patient,high23,normal23,low23,1,2,3,new Date());
                HealthIndexStatistics healthIndexStatistics3 = new HealthIndexStatistics(patient,high33,normal33,low33,1,3,3,new Date());
                HealthIndexStatistics healthIndexStatistics4 = new HealthIndexStatistics(patient,high43,normal43,low43,1,4,3,new Date());
                HealthIndexStatistics healthIndexStatistics5 = new HealthIndexStatistics(patient,high53,normal53,low53,1,5,3,new Date());
                HealthIndexStatistics healthIndexStatistics6 = new HealthIndexStatistics(patient,high63,normal63,low63,1,6,3,new Date());
                HealthIndexStatistics healthIndexStatistics7 = new HealthIndexStatistics(patient,high73,normal73,low73,1,7,3,new Date());
                statisticsList.add(healthIndexStatistics1);
                statisticsList.add(healthIndexStatistics2);
                statisticsList.add(healthIndexStatistics3);
                statisticsList.add(healthIndexStatistics4);
                statisticsList.add(healthIndexStatistics5);
                statisticsList.add(healthIndexStatistics6);
                statisticsList.add(healthIndexStatistics7);
            }
            list.add(healthIndex1);
            list.add(healthIndex2);
@ -242,6 +482,7 @@ public class HealthIndexService extends BaseService {
            list.add(healthIndex7);
            cal.add(Calendar.DAY_OF_YEAR,-1);
        }
        healthIndexStatisticsDao.save(statisticsList);
        return list;
    }
@ -252,13 +493,25 @@ public class HealthIndexService extends BaseService {
     * @param idcard
     */
    public List<HealthIndex> xueya(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){
        String startTime = DateUtil.getStringDateShort()+" 00:00:00";
        String endTime = DateUtil.getStringDateShort()+" 23:59:59";
        HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"2",startTime,endTime);
        if(healthIndex!=null){//判断是否已经生成过数据
            return list;
        }
        Calendar cal = Calendar.getInstance();
        int value1,value2,value3,value4,intValue1,intValue2;
        //140/90mmHg至160/95mmHg之间,不能确定为高血压
        //成年人收缩压90-139.舒张压60-89为正常
        HealthIndex healthIndex = null;
        int high=140,normal=90,low=60;
        int high11=0,normal11=0,low11=0,high12=0,normal12=0,low12=0,high13=0,normal13=0,low13=0;//1为近一个月,2为近半年,3为近一年
        int high21=0,normal21=0,low21=0,high22=0,normal22=0,low22=0,high23=0,normal23=0,low23=0;//1为近一个月,2为近半年,3为近一年
        int high31=0,normal31=0,low31=0,high32=0,normal32=0,low32=0,high33=0,normal33=0,low33=0;//1为近一个月,2为近半年,3为近一年
        Random random = new Random();
        int month = 30;//一个月取30天
        int halfYear = 182;//半年取182天
        age = age>65?65:age;
        if("2".equals(sex)){
            intValue1 = 82+age;
@ -275,6 +528,8 @@ public class HealthIndexService extends BaseService {
                intValue2 = 81-random.nextInt(3);
            }
        }
        List<HealthIndexStatistics> statisticsList = new ArrayList<>();
        for (int i = 0;i<365;i++){
            value1 = intValue1;//收缩压
            value2 = intValue2;//舒张压
@ -294,7 +549,77 @@ public class HealthIndexService extends BaseService {
            }
            value3 = random.nextInt(2)==1?(value2+random.nextInt(9)):(value2-random.nextInt(9));//心率
            value4 = random.nextInt(10)>8?1:0;//心率是否不齐
            value4 = random.nextInt(100)>96?1:0;//心率是否不齐
            //统计数据
            int flag1 = ETLConstantData.ssy(value1);
            int flag2 = ETLConstantData.szy(value2);
            int flag3 = ETLConstantData.heartRate(value3);
            if(flag1>0){
                high11 += i<month?1:0;
                high12 += i<halfYear?1:0;
                high13 ++;
            }else if(flag1<0){
                low11 += i<month?1:0;
                low12 += i<halfYear?1:0;
                low13 ++;
            }else{
                normal11 += i<month?1:0;
                normal12 += i<halfYear?1:0;
                normal13 ++;
            }
            if(flag2>0){
                high21 += i<month?1:0;
                high22 += i<halfYear?1:0;
                high23 ++;
            }else if(flag2<0){
                low21 += i<month?1:0;
                low22 += i<halfYear?1:0;
                low23 ++;
            }else{
                normal21 += i<month?1:0;
                normal22 += i<halfYear?1:0;
                normal23 ++;
            }
            if(flag3>0){
                high31 += i<month?1:0;
                high32 += i<halfYear?1:0;
                high33 ++;
            }
//            else if(flag3<0){
//                low31 += i<month?1:0;
//                low31 += i<halfYear?1:0;
//                low31 ++;
//            }
            else{
                normal31 += i<month?1:0;
                normal32 += i<halfYear?1:0;
                normal33 ++;
            }
            if(i==29){
                HealthIndexStatistics healthIndexStatistics1 = new HealthIndexStatistics(patient,high11,normal11,low11,2,8,1,new Date());
                HealthIndexStatistics healthIndexStatistics2 = new HealthIndexStatistics(patient,high21,normal21,low21,2,9,1,new Date());
                HealthIndexStatistics healthIndexStatistics3 = new HealthIndexStatistics(patient,high31,normal31,low31,2,10,1,new Date());
                statisticsList.add(healthIndexStatistics1);
                statisticsList.add(healthIndexStatistics2);
                statisticsList.add(healthIndexStatistics3);
            }
            if(i==181){
                HealthIndexStatistics healthIndexStatistics1 = new HealthIndexStatistics(patient,high12,normal12,low12,2,8,2,new Date());
                HealthIndexStatistics healthIndexStatistics2 = new HealthIndexStatistics(patient,high22,normal22,low22,2,9,2,new Date());
                HealthIndexStatistics healthIndexStatistics3 = new HealthIndexStatistics(patient,high32,normal32,low32,2,10,2,new Date());
                statisticsList.add(healthIndexStatistics1);
                statisticsList.add(healthIndexStatistics2);
                statisticsList.add(healthIndexStatistics3);
            }
            if(i==364){
                HealthIndexStatistics healthIndexStatistics1 = new HealthIndexStatistics(patient,high13,normal13,low13,2,8,3,new Date());
                HealthIndexStatistics healthIndexStatistics2 = new HealthIndexStatistics(patient,high23,normal23,low23,2,9,3,new Date());
                HealthIndexStatistics healthIndexStatistics3 = new HealthIndexStatistics(patient,high33,normal33,low33,2,10,3,new Date());
                statisticsList.add(healthIndexStatistics1);
                statisticsList.add(healthIndexStatistics2);
                statisticsList.add(healthIndexStatistics3);
            }
            healthIndex.setCzrq(new Date());
            healthIndex.setDel("1");
@ -310,6 +635,7 @@ public class HealthIndexService extends BaseService {
            list.add(healthIndex);
            cal.add(Calendar.DAY_OF_YEAR,-1);
        }
        healthIndexStatisticsDao.save(statisticsList);
        return list;
    }
@ -320,6 +646,13 @@ public class HealthIndexService extends BaseService {
     * @param idcard
     */
    public List<HealthIndex> weight(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){
        String startTime = DateUtil.getStringDateShort()+" 00:00:00";
        String endTime = DateUtil.getStringDateShort()+" 23:59:59";
        HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"3",startTime,endTime);
        if(healthIndex!=null){//判断是否已经生成过数据
            return list;
        }
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY,0);
        cal.set(Calendar.MINUTE,0);
@ -348,7 +681,6 @@ public class HealthIndexService extends BaseService {
        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();
@ -433,13 +765,19 @@ public class HealthIndexService extends BaseService {
     * @param idcard
     */
    public List<HealthIndex> yaowei(String patient, String deviceSn, String idcard, int age, String sex, List<HealthIndex> list){
        String startTime = DateUtil.getStringDateShort()+" 00:00:00";
        String endTime = DateUtil.getStringDateShort()+" 23:59:59";
        HealthIndex healthIndex = healthIndexDao.findByPatientAndType(patient,"4",startTime,endTime);
        if(healthIndex!=null){//判断是否已经生成过数据
            return 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();

+ 16 - 0
patient-co-figure/src/main/java/com/yihu/figure/service/HealthIndexStatisticsService.java

@ -0,0 +1,16 @@
package com.yihu.figure.service;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
/**
 * 体征统计
 * Created by yeshijie on 2017/3/6.
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class HealthIndexStatisticsService extends BaseService {
}

+ 176 - 0
patient-co-figure/src/main/java/com/yihu/figure/util/ETLConstantData.java

@ -0,0 +1,176 @@
package com.yihu.figure.util;
/**
 * Created by lyr-pc on 2017/2/20.
 */
public class ETLConstantData {
    /***************************体征指标正常范围*******************************/
    // 血糖餐前最小值
    public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
    // 血糖餐前最大值
    public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
    // 血糖餐后最小值
    public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
    // 血糖餐后最大值
    public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
    // 舒张压最小值
    public static final int HEALTH_STANDARD_SZY_MIN = 60;
    // 舒张压最大值
    public static final int HEALTH_STANDARD_SZY_MAX = 90;
    // 收缩压最小值
    public static final int HEALTH_STANDARD_SSY_MIN = 90;
    // 收缩压最大值
    public static final int HEALTH_STANDARD_SSY_MAX = 140;
    /**
     * 性别
     *
     * @return
     */
    public static String sexName(int sex) {
        switch (sex) {
            case 1:
                return "男";
            case 2:
                return "女";
            default:
                return "其他";
        }
    }
    /**
     * 年龄段
     *
     * @param age
     * @return
     */
    public static String ageInterval(int age) {
        if (age < 7) {
            return "儿童";
        } else if (age >= 7 && age <= 14) {
            return "少年";
        } else if (age >= 15 && age <= 35) {
            return "青年";
        } else if (age >= 36 && age <= 60) {
            return "中年";
        } else {
            return "老年";
        }
    }
    /**
     * 获取城市名称
     *
     * @param city
     * @return
     */
    public static String cityName(String city) {
        return "";
    }
    /**
     * 体质指数转换
     *
     * @param bmi
     * @return
     */
    public static String bmiName(double bmi) {
        if (bmi < 18.5) {
            return "偏瘦";
        } else if (bmi >= 18.5 && bmi < 24) {
            return "体重正常";
        } else if (bmi >= 24 && bmi < 27) {
            return "超重";
        } else if (bmi >= 27 && bmi < 30) {
            return "偏胖";
        } else if (bmi >= 30 && bmi < 35) {
            return "肥胖";
        } else if (bmi >= 35 && bmi < 40) {
            return "重度肥胖";
        } else {
            return "极重度肥胖";
        }
    }
    /**
     * 心律情况
     *
     * @param rate
     * @return
     */
    public static int heartRate(double rate) {
        if (rate >= 40 && rate <= 160) {
            return 0;//"心率正常";
        } else {
            return 1;//"心率不正常";
        }
    }
    /**
     * 空腹血糖判断
     *
     * @param value
     * @return
     */
    public static int xueTangBefore(double value) {
        if (value < ETLConstantData.HEALTH_STANDARD_ST_MIN_BEFORE) {
            return -1;
        }
        if (value > ETLConstantData.HEALTH_STANDARD_ST_MAX_BEFORE) {
            return 1;
        }
        return 0;
    }
    /**
     * 餐后血糖判断
     *
     * @param value
     * @return
     */
    public static int xueTangAfter(double value) {
        if (value < ETLConstantData.HEALTH_STANDARD_ST_MIN_AFTER) {
            return -1;
        }
        if (value > ETLConstantData.HEALTH_STANDARD_ST_MAX_AFTER) {
            return 1;
        }
        return 0;
    }
    /**
     * 收缩压比较
     *
     * @param value
     * @return
     */
    public static int ssy(double value) {
        if (value < ETLConstantData.HEALTH_STANDARD_SSY_MIN) {
            return -1;
        }
        if (value > ETLConstantData.HEALTH_STANDARD_SSY_MAX) {
            return 1;
        }
        return 0;
    }
    /**
     * 舒张压比较
     *
     * @param value
     * @returnz
     */
    public static int szy(double value) {
        if (value < ETLConstantData.HEALTH_STANDARD_SZY_MIN) {
            return -1;
        }
        if (value > ETLConstantData.HEALTH_STANDARD_SZY_MAX) {
            return 1;
        }
        return 0;
    }
}

Різницю між файлами не показано, бо вона завелика
+ 28 - 0
patient-co-figure/src/main/java/com/yihu/figure/web/HealthIndexController.java