Bläddra i källkod

Merge branch 'dev' of wujunjie/patient-management into dev

linzhuo 8 år sedan
förälder
incheckning
76bd03abd7

+ 226 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientBloodSugger.java

@ -0,0 +1,226 @@
package com.yihu.wlyy.entity.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import javax.persistence.*;
import java.util.Date;
/**
 * Created by Reece on 2017/5/11.
 */
@Entity
@Table(name = "wlyy_patient_blood_sugger")
public class PatientBloodSugger extends IdEntity {
    //    早餐前开始时间
    private String fastingStart;
    //    '早餐前截止时间'
    private String fastingEnd;
    //    '早餐后开始时间'
    private String afterBreakfastStart;
    //    '早餐后截止时间'
    private String afterBreakfastEnd;
    //    '午餐前开始时间'
    private String beforeLunchStart;
    //    '午餐前截止时间'
    private String beforeLunchEnd;
    //    '午餐后开始时间'
    private String afterLunchStart;
    //    '午餐后截止时间'
    private String afterLunchEnd;
    //    '晚餐前开始时间'
    private String beforeDinnerStart;
    //    '晚餐前截止时间'
    private String beforeDinnerEnd;
    //    '晚餐后开始时间'
    private String afterDinnerStart;
    //    '晚餐后截止时间'
    private String afterDinnerEnd;
    //    '睡前开始时间'
    private String beforeSleepStart;
    //    '睡前截止时间'
    private String beforeSleepEnd;
    //    '添加时间'
    private Date czrq;
    //    是否作废,1正常,0作废
    private int del;
    public PatientBloodSugger() {
    }
    @Column(name = "fasting_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getFastingStart() {
        return fastingStart;
    }
    public void setFastingStart(String fastingStart) {
        this.fastingStart = fastingStart;
    }
    @Column(name = "fasting_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getFastingEnd() {
        return fastingEnd;
    }
    public void setFastingEnd(String fastingEnd) {
        this.fastingEnd = fastingEnd;
    }
    @Column(name = "after_breakfast_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterBreakfastStart() {
        return afterBreakfastStart;
    }
    public void setAfterBreakfastStart(String afterBreakfastStart) {
        this.afterBreakfastStart = afterBreakfastStart;
    }
    @Column(name = "after_breakfast_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterBreakfastEnd() {
        return afterBreakfastEnd;
    }
    public void setAfterBreakfastEnd(String afterBreakfastEnd) {
        this.afterBreakfastEnd = afterBreakfastEnd;
    }
    @Column(name = "before_lunch_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeLunchStart() {
        return beforeLunchStart;
    }
    public void setBeforeLunchStart(String beforeLunchStart) {
        this.beforeLunchStart = beforeLunchStart;
    }
    @Column(name = "before_lunch_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeLunchEnd() {
        return beforeLunchEnd;
    }
    public void setBeforeLunchEnd(String beforeLunchEnd) {
        this.beforeLunchEnd = beforeLunchEnd;
    }
    @Column(name = "after_lunch_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterLunchStart() {
        return afterLunchStart;
    }
    public void setAfterLunchStart(String afterLunchStart) {
        this.afterLunchStart = afterLunchStart;
    }
    @Column(name = "after_lunch_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterLunchEnd() {
        return afterLunchEnd;
    }
    public void setAfterLunchEnd(String afterLunchEnd) {
        this.afterLunchEnd = afterLunchEnd;
    }
    @Column(name = "before_dinner_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeDinnerStart() {
        return beforeDinnerStart;
    }
    public void setBeforeDinnerStart(String beforeDinnerStart) {
        this.beforeDinnerStart = beforeDinnerStart;
    }
    @Column(name = "before_dinner_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeDinnerEnd() {
        return beforeDinnerEnd;
    }
    public void setBeforeDinnerEnd(String beforeDinnerEnd) {
        this.beforeDinnerEnd = beforeDinnerEnd;
    }
    @Column(name = "after_dinner_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterDinnerStart() {
        return afterDinnerStart;
    }
    public void setAfterDinnerStart(String afterDinnerStart) {
        this.afterDinnerStart = afterDinnerStart;
    }
    @Column(name = "after_dinner_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterDinnerEnd() {
        return afterDinnerEnd;
    }
    public void setAfterDinnerEnd(String afterDinnerEnd) {
        this.afterDinnerEnd = afterDinnerEnd;
    }
    @Column(name = "before_sleep_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeSleepStart() {
        return beforeSleepStart;
    }
    public void setBeforeSleepStart(String beforeSleepStart) {
        this.beforeSleepStart = beforeSleepStart;
    }
    @Column(name = "before_sleep_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeSleepEnd() {
        return beforeSleepEnd;
    }
    public void setBeforeSleepEnd(String beforeSleepEnd) {
        this.beforeSleepEnd = beforeSleepEnd;
    }
    @Column(name = "czrq")
    @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;
    }
    public int getDel() {
        return del;
    }
    public void setDel(int del) {
        this.del = del;
    }
}

+ 248 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientHealthTime.java

@ -0,0 +1,248 @@
package com.yihu.wlyy.entity.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import javax.persistence.*;
import java.util.Date;
/**
 * Created by Reece on 2017/5/11.
 */
@Entity
@Table(name = "wlyy_patient_health_time")
public class PatientHealthTime extends IdEntity {
    //    居民
    private String user;
    //    设备sn码
    private String deviceSN;
    //    早餐前开始时间
    private String fastingStart;
    //    '早餐前截止时间'
    private String fastingEnd;
    //    '早餐后开始时间'
    private String afterBreakfastStart;
    //    '早餐后截止时间'
    private String afterBreakfastEnd;
    //    '午餐前开始时间'
    private String beforeLunchStart;
    //    '午餐前截止时间'
    private String beforeLunchEnd;
    //    '午餐后开始时间'
    private String afterLunchStart;
    //    '午餐后截止时间'
    private String afterLunchEnd;
    //    '晚餐前开始时间'
    private String beforeDinnerStart;
    //    '晚餐前截止时间'
    private String beforeDinnerEnd;
    //    '晚餐后开始时间'
    private String afterDinnerStart;
    //    '晚餐后截止时间'
    private String afterDinnerEnd;
    //    '睡前开始时间'
    private String beforeSleepStart;
    //    '睡前截止时间'
    private String beforeSleepEnd;
    //    '添加时间'
    private Date czrq;
    //    是否作废,1正常,0作废
    private int del;
    public PatientHealthTime() {
    }
    @Column(name = "user")
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    @Column(name = "device_sn")
    public String getDeviceSN() {
        return deviceSN;
    }
    public void setDeviceSN(String deviceSN) {
        this.deviceSN = deviceSN;
    }
    @Column(name = "fasting_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getFastingStart() {
        return fastingStart;
    }
    public void setFastingStart(String fastingStart) {
        this.fastingStart = fastingStart;
    }
    @Column(name = "fasting_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getFastingEnd() {
        return fastingEnd;
    }
    public void setFastingEnd(String fastingEnd) {
        this.fastingEnd = fastingEnd;
    }
    @Column(name = "after_breakfast_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterBreakfastStart() {
        return afterBreakfastStart;
    }
    public void setAfterBreakfastStart(String afterBreakfastStart) {
        this.afterBreakfastStart = afterBreakfastStart;
    }
    @Column(name = "after_breakfast_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterBreakfastEnd() {
        return afterBreakfastEnd;
    }
    public void setAfterBreakfastEnd(String afterBreakfastEnd) {
        this.afterBreakfastEnd = afterBreakfastEnd;
    }
    @Column(name = "before_lunch_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeLunchStart() {
        return beforeLunchStart;
    }
    public void setBeforeLunchStart(String beforeLunchStart) {
        this.beforeLunchStart = beforeLunchStart;
    }
    @Column(name = "before_lunch_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeLunchEnd() {
        return beforeLunchEnd;
    }
    public void setBeforeLunchEnd(String beforeLunchEnd) {
        this.beforeLunchEnd = beforeLunchEnd;
    }
    @Column(name = "after_lunch_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterLunchStart() {
        return afterLunchStart;
    }
    public void setAfterLunchStart(String afterLunchStart) {
        this.afterLunchStart = afterLunchStart;
    }
    @Column(name = "after_lunch_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterLunchEnd() {
        return afterLunchEnd;
    }
    public void setAfterLunchEnd(String afterLunchEnd) {
        this.afterLunchEnd = afterLunchEnd;
    }
    @Column(name = "before_dinner_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeDinnerStart() {
        return beforeDinnerStart;
    }
    public void setBeforeDinnerStart(String beforeDinnerStart) {
        this.beforeDinnerStart = beforeDinnerStart;
    }
    @Column(name = "before_dinner_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeDinnerEnd() {
        return beforeDinnerEnd;
    }
    public void setBeforeDinnerEnd(String beforeDinnerEnd) {
        this.beforeDinnerEnd = beforeDinnerEnd;
    }
    @Column(name = "after_dinner_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterDinnerStart() {
        return afterDinnerStart;
    }
    public void setAfterDinnerStart(String afterDinnerStart) {
        this.afterDinnerStart = afterDinnerStart;
    }
    @Column(name = "after_dinner_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getAfterDinnerEnd() {
        return afterDinnerEnd;
    }
    public void setAfterDinnerEnd(String afterDinnerEnd) {
        this.afterDinnerEnd = afterDinnerEnd;
    }
    @Column(name = "before_sleep_start")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeSleepStart() {
        return beforeSleepStart;
    }
    public void setBeforeSleepStart(String beforeSleepStart) {
        this.beforeSleepStart = beforeSleepStart;
    }
    @Column(name = "before_sleep_end")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+08:00")
    public String getBeforeSleepEnd() {
        return beforeSleepEnd;
    }
    public void setBeforeSleepEnd(String beforeSleepEnd) {
        this.beforeSleepEnd = beforeSleepEnd;
    }
    @Column(name = "czrq")
    @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;
    }
    public int getDel() {
        return del;
    }
    public void setDel(int del) {
        this.del = del;
    }
}

+ 61 - 59
patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -5,6 +5,7 @@ import io.swagger.models.auth.In;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.jca.cci.core.InteractionCallback;
@ -13,68 +14,69 @@ import java.util.Date;
import java.util.List;
public interface DevicePatientHealthIndexDao
		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
	 List<DevicePatientHealthIndex> findByIdcardAndType(String idcard,Integer type);
	/**
	 * 按录入时间和患者标识查询健康记录
	 * @param patientCode
	 * @param date
	 * @return
	 */
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and type = ?2 and a.recordDate = ?3 and a.del = '1'")
	Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date);
	
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate between ?3 and ?4 and a.del = '1' group by recordDate order by recordDate asc")
	Iterable<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
	
	@Query("select a.value1 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value1 > 0 order by recordDate desc")
	Page<String> findValue1ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	
	@Query("select a.value2 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value2 > 0 order by recordDate desc")
	Page<String> findValue2ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	
	@Query("select a.value3 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value3 > 0 order by recordDate desc")
	Page<String> findValue3ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	
	@Query("select a.value4 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value4 > 0 order by recordDate desc")
	Page<String> findValue4ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	
	@Query("select a.value5 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value5 > 0 order by recordDate desc")
	Page<String> findValue5ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	
	@Query("select a.value6 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value6 > 0 order by recordDate desc")
	Page<String> findValue6ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	
	@Query("select a.value7 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value7 > 0 order by recordDate desc")
	Page<String> findValue7ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate >= ?3 and a.recordDate <= ?4 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
	List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
	@Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 order by a.recordDate desc ")
	Iterable<DevicePatientHealthIndex> findRecentByPatient(String patient);
	@Query("select DATE_FORMAT(a.recordDate,'%Y-%m-%d') from DevicePatientHealthIndex a where a.user = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' group by DATE_FORMAT(a.recordDate,'%Y-%m-%d') order by DATE_FORMAT(a.recordDate,'%Y-%m-%d') desc")
	List<String> findDateList(String patient, Date start, Date end, Pageable pageRequest);
	/**
	 * 获取患者一天血糖值
        extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
    List<DevicePatientHealthIndex> findByIdcardAndType(String idcard, Integer type);
    /**
     * 按录入时间和患者标识查询健康记录
     *
     * @param patientCode
     * @param date
     * @return
     */
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and type = ?2 and a.recordDate = ?3 and a.del = '1'")
    Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date);
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate between ?3 and ?4 and a.del = '1' group by recordDate order by recordDate asc")
    Iterable<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
    @Query("select a.value1 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value1 > 0 order by recordDate desc")
    Page<String> findValue1ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value2 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value2 > 0 order by recordDate desc")
    Page<String> findValue2ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value3 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value3 > 0 order by recordDate desc")
    Page<String> findValue3ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value4 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value4 > 0 order by recordDate desc")
    Page<String> findValue4ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value5 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value5 > 0 order by recordDate desc")
    Page<String> findValue5ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value6 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value6 > 0 order by recordDate desc")
    Page<String> findValue6ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a.value7 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value7 > 0 order by recordDate desc")
    Page<String> findValue7ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate >= ?3 and a.recordDate <= ?4 and a.del = '1'")
    Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Date start, Date end, Pageable pageRequest);
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
    List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
    @Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 order by a.recordDate desc ")
    Iterable<DevicePatientHealthIndex> findRecentByPatient(String patient);
    @Query("select DATE_FORMAT(a.recordDate,'%Y-%m-%d') from DevicePatientHealthIndex a where a.user = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' group by DATE_FORMAT(a.recordDate,'%Y-%m-%d') order by DATE_FORMAT(a.recordDate,'%Y-%m-%d') desc")
    List<String> findDateList(String patient, Date start, Date end, Pageable pageRequest);
    /**
     * 获取患者一天血糖值
     */
	@Query("select a from DevicePatientHealthIndex a where a.type=1 and a.user = ?1 and DATE_FORMAT(a.recordDate,'%Y-%m-%d') = ?2 order by a.recordDate,a.id")
	List<DevicePatientHealthIndex> findByDate(String patient, String date);
    @Query("select a from DevicePatientHealthIndex a where a.type=1 and a.user = ?1 and DATE_FORMAT(a.recordDate,'%Y-%m-%d') = ?2 order by a.recordDate,a.id")
    List<DevicePatientHealthIndex> findByDate(String patient, String date);
	@Query(value = "select a.* from device.wlyy_patient_health_index a where a.user=?1 and a.type=?2 order by a.record_date desc limit 0,1",nativeQuery = true)
	DevicePatientHealthIndex findLastData(String patient, Integer type);
    @Query(value = "select a.* from device.wlyy_patient_health_index a where a.user=?1 and a.type=?2 order by a.record_date desc limit 0,1", nativeQuery = true)
    DevicePatientHealthIndex findLastData(String patient, Integer type);
	/**
	 * 上次血糖值
    /**
     * 上次血糖值
     */
	@Query(value = "select a.value1 from device.wlyy_patient_health_index a where a.type=1 and a.user = ?1 and a.id<?2 and a.value2 = ?3 order by a.record_date desc limit 0,1",nativeQuery = true)
	String getPreValue(String user,Long id,String value2);
    @Query(value = "select a.value1 from device.wlyy_patient_health_index a where a.type=1 and a.user = ?1 and a.id<?2 and a.value2 = ?3 order by a.record_date desc limit 0,1", nativeQuery = true)
    String getPreValue(String user, Long id, String value2);
}

+ 14 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/PatientBloodSuggerDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.deviece;
import com.yihu.wlyy.entity.device.PatientBloodSugger;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/5/11.
 */
public interface PatientBloodSuggerDao extends PagingAndSortingRepository<PatientBloodSugger,Long> {
//    按ID倒序查最近的有效默认时间段
    @Query(value = "select t.* from device.wlyy_patient_blood_sugger t where t.del = 1 order by t.id desc limit 0,1 ",nativeQuery = true)
    PatientBloodSugger findRecent();
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/PatientHealthTimeDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.deviece;
import com.yihu.wlyy.entity.device.PatientHealthTime;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/5/11.
 */
public interface PatientHealthTimeDao extends PagingAndSortingRepository<PatientHealthTime, Long> {
    //    根据居民和设备sn码查询自定义的血糖时间段
    @Query(value = "select t.* from wlyy_patient_health_time t where t.del = 1 and t.user = ?1 and t.device_sn = ?2 ", nativeQuery = true)
    PatientHealthTime findByUserAndSN(String user, String deviceSN);
    //    根据居民和设备sn码查询自定义的血糖时间段
    @Query(value = "select t.* from wlyy_patient_health_time t where t.del = 1 and t.user = ?1 and t.device_sn = ?2 ", nativeQuery = true)
    PatientHealthTime findBycUserAndSN(String user, String deviceSN);
}

+ 489 - 386
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -1,11 +1,15 @@
package com.yihu.wlyy.service.app.device;
import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientBloodSugger;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientHealthTime;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.deviece.DeviceDao;
import com.yihu.wlyy.repository.deviece.PatientBloodSuggerDao;
import com.yihu.wlyy.repository.deviece.PatientHealthTimeDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
@ -37,393 +41,492 @@ import java.util.*;
@Transactional(rollbackFor = Exception.class)
public class PatientDeviceService extends BaseService {
	private Clock clock = Clock.DEFAULT;
	@Autowired
	private DoctorDao doctorDao;
	@Autowired
	private PatientDeviceDao patientDeviceDao;
	@Autowired
	private DeviceDao deviceDao;
	@Autowired
	private PatientDao patientDao;
	@Autowired
	private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
	@Autowired
	private AdminTeamService adminTeamService;
	private String url = SystemConf.getInstance().getYihuOpenPlatformUrl();
	private String appid = SystemConf.getInstance().getYihuOpenPlatformAppId();
	private String secret = SystemConf.getInstance().getYihuOpenPlatformSecret();
	private String registerDevice = "DeviceGateway/DeviceApi/registerDevice";//注册设备
	/**
	 * 保存患者设备
	 */
	public boolean saveDevice(PatientDevice patientDevice) throws Exception {
		synchronized (patientDevice.getDeviceSn()){
			//判断sn码是否被使用
			String sn = patientDevice.getDeviceSn();
			String type =  patientDevice.getCategoryCode();
			Long deviceId =  patientDevice.getDeviceId();
			String userType = patientDevice.getUserType();
			if(userType == null)
			{
				userType = "-1";
				patientDevice.setUserType("-1");
			}
			boolean needVerify = true;
			//修改操作
			if(patientDevice.getId()!=null)
			{
				PatientDevice deviceOld =  patientDeviceDao.findOne(patientDevice.getId());
				if(deviceOld!=null)
				{
					if(deviceOld.getDeviceSn().equals(sn))
					{
						needVerify = false;
					}
				}
				else{
					throw new Exception("不存在该条记录!");
				}
			}
			//校验sn码是否被使用
			if(needVerify) {
    private Clock clock = Clock.DEFAULT;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DeviceDao deviceDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
    private PatientBloodSuggerDao patientBloodSuggerDao;
    @Autowired
    private PatientHealthTimeDao patientHealthTimeDao;
    private String url = SystemConf.getInstance().getYihuOpenPlatformUrl();
    private String appid = SystemConf.getInstance().getYihuOpenPlatformAppId();
    private String secret = SystemConf.getInstance().getYihuOpenPlatformSecret();
    private String registerDevice = "DeviceGateway/DeviceApi/registerDevice";//注册设备
    /**
     * 保存患者设备
     */
    public boolean saveDevice(PatientDevice patientDevice) throws Exception {
        synchronized (patientDevice.getDeviceSn()) {
            //判断sn码是否被使用
            String sn = patientDevice.getDeviceSn();
            String type = patientDevice.getCategoryCode();
            Long deviceId = patientDevice.getDeviceId();
            String userType = patientDevice.getUserType();
            if (userType == null) {
                userType = "-1";
                patientDevice.setUserType("-1");
            }
            boolean needVerify = true;
            //修改操作
            if (patientDevice.getId() != null) {
                PatientDevice deviceOld = patientDeviceDao.findOne(patientDevice.getId());
                if (deviceOld != null) {
                    if (deviceOld.getDeviceSn().equals(sn)) {
                        needVerify = false;
                    }
                } else {
                    throw new Exception("不存在该条记录!");
                }
            }
            //校验sn码是否被使用
            if (needVerify) {
//				PatientDevice device = patientDeviceDao.findByDeviceIdAndDeviceSnAndUserType(deviceId, sn, userType);
				PatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
				if (device != null && !device.getId().equals(patientDevice.getId())) {
					throw new Exception("sn码" + sn + "已被使用!");
				}
			}
			patientDevice.setCzrq(clock.getCurrentDate());
			//当前用户的身份证
			Patient patient = patientDao.findByCode(patientDevice.getUser());
			patientDevice.setUserIdcard(patient.getIdcard());
			//注册设备
			Map<String, String> params = new HashMap<>();
			params.put("deviceSn", sn);
			//调用服务
			String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
			System.out.println("注册设备="+response);
			JSONObject json = new JSONObject(response);
			String code = json.get("Code").toString();
			//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
			if("10000".equals(code)||"10001".equals(code))
			{
				patientDeviceDao.save(patientDevice);
			}else{
				String message = json.get("Message").toString();
				throw new Exception(message);
			}
			return true;
		}
	}
	/**
	 * 注册设备
	 * @return
	 * @throws Exception
                PatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
                if (device != null && !device.getId().equals(patientDevice.getId())) {
                    throw new Exception("sn码" + sn + "已被使用!");
                }
            }
            patientDevice.setCzrq(clock.getCurrentDate());
            //当前用户的身份证
            Patient patient = patientDao.findByCode(patientDevice.getUser());
            patientDevice.setUserIdcard(patient.getIdcard());
            //注册设备
            Map<String, String> params = new HashMap<>();
            params.put("deviceSn", sn);
            //调用服务
            String response = HttpClientUtil.httpPost(url + registerDevice, HttpClientUtil.getSecretParams(params, appid, secret));
            System.out.println("注册设备=" + response);
            JSONObject json = new JSONObject(response);
            String code = json.get("Code").toString();
            //10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
            if ("10000".equals(code) || "10001".equals(code)) {
                patientDeviceDao.save(patientDevice);
            } else {
                String message = json.get("Message").toString();
                throw new Exception(message);
            }
            return true;
        }
    }
    /**
     * 注册设备
     *
     * @return
     * @throws Exception
     */
	public String registerSnInit() throws Exception{
		String re = "";
		Iterable<PatientDevice> iterable = patientDeviceDao.findAll();
		if(iterable!=null){
			for (PatientDevice patientDevice:iterable){
				String deviceSn = patientDevice.getDeviceSn();
				Map<String, String> params = new HashMap<>();
				params.put("deviceSn", deviceSn);
				String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
				System.out.println("注册设备="+response);
				JSONObject json = new JSONObject(response);
				String code = json.get("Code").toString();
				//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
				if("10000".equals(code)||"10001".equals(code))
				{
				}else{
					String message = json.get("Message").toString();
					re+= deviceSn + message +";";
				}
			}
		}
		return re;
	}
	/**
	 * 单个注册
	 * @param deviceSn
	 * @return
	 * @throws Exception
    public String registerSnInit() throws Exception {
        String re = "";
        Iterable<PatientDevice> iterable = patientDeviceDao.findAll();
        if (iterable != null) {
            for (PatientDevice patientDevice : iterable) {
                String deviceSn = patientDevice.getDeviceSn();
                Map<String, String> params = new HashMap<>();
                params.put("deviceSn", deviceSn);
                String response = HttpClientUtil.httpPost(url + registerDevice, HttpClientUtil.getSecretParams(params, appid, secret));
                System.out.println("注册设备=" + response);
                JSONObject json = new JSONObject(response);
                String code = json.get("Code").toString();
                //10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
                if ("10000".equals(code) || "10001".equals(code)) {
                } else {
                    String message = json.get("Message").toString();
                    re += deviceSn + message + ";";
                }
            }
        }
        return re;
    }
    /**
     * 单个注册
     *
     * @param deviceSn
     * @return
     * @throws Exception
     */
	public String registerSn(String deviceSn) throws Exception{
		Map<String, String> params = new HashMap<>();
		params.put("deviceSn", deviceSn);
		String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
		return response;
	}
	public void deleteDevices(String deviceSn,String type,String uuid){
		List<PatientDevice> patientDevices = 	patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn,type);
		if(patientDevices==null||patientDevices.size()==0){
			throw  new RuntimeException("设备未被绑定!");
		}
		for(PatientDevice patientDevice: patientDevices){
			patientDeviceDao.delete(patientDevice);
		}
	}
	/**
	 * 删除患者设备
	 */
	public List<JSONObject> deleteDevice(String id,String uuid) {
		PatientDevice device = patientDeviceDao.findOne(Long.valueOf(id));
		patientDeviceDao.delete(device);
		List<PatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(device.getDeviceSn(),device.getCategoryCode());
		List<JSONObject> objects = new ArrayList<>();
		for(PatientDevice patientDevice:patientDevices){
			JSONObject object = new JSONObject(patientDevice);
			Patient patient = patientDao.findByCode(patientDevice.getUser());
			if(patient!=null){
				object.put("userName",patient.getName());
			}
			objects.add(object);
		}
		return objects;
	}
	/**
	 * 患者设备列表接口(分页)
	 */
	public Page<PatientDevice> findByPatient(String patientCode, long id, int pageSize) {
		if (id < 0) {
			id = 0;
		}
		if (pageSize <= 0) {
			pageSize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pageSize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		filters.put("patient", new SearchFilter("user", Operator.EQ, patientCode));
		//filters.put("del", new SearchFilter("del", Operator.EQ, 0));
		if(id > 0){
			filters.put("id", new SearchFilter("id", Operator.LT, id));
		}
		Specification<PatientDevice> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientDevice.class);
		return patientDeviceDao.findAll(spec, pageRequest);
	}
	/**
	 * 患者设备列表接口--医生端
	 */
	public List<Map<String,Object>> findByDoctor(String patientCode,String doctorCode, int page, int pagesize) {
		List<Map<String,Object>> re = new ArrayList<>();
		if (page <= 0) {
			page = 1;
		}
		if (pagesize <= 0) {
			pagesize = 10;
		}
		//boolean bo = false;
		////判断该医生是否属于患者的签约行政团队
		//List<AdminTeamMember> adminTeamMembers = doctorAdminTeamMemberDao.findByAdminTeam(patientCode,doctorCode);
		//if(adminTeamMembers!=null && adminTeamMembers.size()>0)
		//{
		//	bo = true;
		//}
		PageRequest pageRequest = new PageRequest(page-1, pagesize);
		List<PatientDevice> list = new ArrayList<>();
		//if(bo) //签约医生查看所有设备
		//{
		//	list = patientDeviceDao.findByUser(patientCode,pageRequest);
		//}
		//else{
		//	list = patientDeviceDao.findByUserAndDoctor(patientCode, doctorCode,pageRequest);
		//}
		list = patientDeviceDao.findByUser(patientCode,pageRequest);
		if(list!=null)
		{
			//获取设备路径,医生姓名
			List<Device> deviceList = deviceDao.findAll();
			Doctor self = doctorDao.findByCode(doctorCode);
			for(PatientDevice item :list)
			{
				Map<String,Object>  map = new HashMap<>();
				if(StringUtils.isNotBlank(item.getDoctor())){
					if(StringUtils.equals(item.getDoctor(),doctorCode)){
						map.put("role",1);//可解绑自己绑定的
					}else{
						List<AdminTeam> adminTeams = adminTeamService.findDoctorsTeams(item.getDoctor(),doctorCode);
						if(adminTeams!=null&&adminTeams.size()>0){
							map.put("role",1);//同行政团队可解绑
						}else{
							map.put("role",0);//不同行政团队不可解绑
						}
					}
				}else{
					map.put("role",0);//患者自己绑定无法解绑
				}
				map.put("id",item.getId()) ;
				map.put("deviceId",item.getDeviceId());
				map.put("deviceSn",item.getDeviceSn());
				map.put("user",item.getUser());
				map.put("categoryCode",item.getCategoryCode());
				map.put("userType",item.getUserType());
				map.put("userIdcard",item.getUserIdcard());
				map.put("czrq", DateUtil.dateToStrLong(item.getCzrq()));
				String deviceDoctor = item.getDoctor();
				if(deviceDoctor == null)
				{
					map.put("doctor","");
					map.put("doctorName","");
				}
				else{
					map.put("doctor",deviceDoctor);
					if(deviceDoctor.equals(doctorCode))
					{
						map.put("doctorName",self.getName());
					}
					else{
						Doctor doctor = doctorDao.findByCode(deviceDoctor);
						if(doctor!=null)
						{
							map.put("doctorName",doctor.getName());
						}
						else{
							map.put("doctorName","");
						}
					}
				}
				//获取设备路径
				for(Device de : deviceList)
				{
					if(de.getId().equals(item.getDeviceId()))
					{
						map.put("deviceName",de.getName());
						map.put("devicePhoto",de.getPhoto());
						map.put("deviceBrands",de.getBrands());
						break;
					}
				}
				re.add(map);
			}
		}
		re.sort(new Comparator<Map<String, Object>>() {
			@Override
			public int compare(Map<String, Object> o1, Map<String, Object> o2) {
				if(o1.get("czrq").toString().compareTo(o2.get("czrq").toString()) > 0){
					return -1;
				}
				if(o1.get("czrq").toString().compareTo(o2.get("czrq").toString()) < 0){
					return 1;
				}
				return 0;
			}
		});
		return re;
	}
	/**
	 * 查询患者已拥有的设备
	 * @param patient
	 * @return
	 */
	public Iterator<PatientDevice> findPatientHave(String patient) {
		return patientDeviceDao.findByUser(patient).iterator();
	}
	/**
	 * 获取患者设备信息
	 **/
	public PatientDevice findById(String id) {
		return patientDeviceDao.findOne(Long.valueOf(id));
	}
	/**
	 * 通过sn码获取设备绑定情况
	 **/
	public List<Map<String,String>> getDeviceUser(String user,String deviceSn,String type) throws Exception {
		List<Map<String,String>> re = new ArrayList<>();
		List<PatientDevice> list =patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn,type);
		if(list!=null)
		{
			for(PatientDevice item:list)
			{
				Map<String,String> map = new HashMap<> ();
				map.put("type",item.getUserType());
				String code = item.getUser();
				if(code.equals(user))
				{
					map.put("others","0");
				}
				else{
					map.put("others","1");
				}
				//获取姓名
				Patient patient = patientDao.findByCode(code);
				if(patient!=null)
				{
					map.put("name",patient.getName());
				}
				else{
					map.put("name",code);
				}
				re.add(map);
			}
		}
		return re;
	}
	public JSONArray getDeviceByDeviceSn(String deviceSn,String type){
		List<PatientDevice> list =patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn,type);
		JSONArray objects = new JSONArray();
		for(PatientDevice patientDevice:list){
			JSONObject object = new JSONObject(patientDevice);
			Patient patient = patientDao.findByCode(patientDevice.getUser());
			if(patient!=null){
				object.put("userName",patient.getName());
			}
			objects.put(object);
		}
		return objects;
	}
    public String registerSn(String deviceSn) throws Exception {
        Map<String, String> params = new HashMap<>();
        params.put("deviceSn", deviceSn);
        String response = HttpClientUtil.httpPost(url + registerDevice, HttpClientUtil.getSecretParams(params, appid, secret));
        return response;
    }
    public void deleteDevices(String deviceSn, String type, String uuid) {
        List<PatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        if (patientDevices == null || patientDevices.size() == 0) {
            throw new RuntimeException("设备未被绑定!");
        }
        for (PatientDevice patientDevice : patientDevices) {
            patientDeviceDao.delete(patientDevice);
        }
    }
    /**
     * 删除患者设备
     */
    public List<JSONObject> deleteDevice(String id, String uuid) {
        PatientDevice device = patientDeviceDao.findOne(Long.valueOf(id));
        patientDeviceDao.delete(device);
        List<PatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(device.getDeviceSn(), device.getCategoryCode());
        List<JSONObject> objects = new ArrayList<>();
        for (PatientDevice patientDevice : patientDevices) {
            JSONObject object = new JSONObject(patientDevice);
            Patient patient = patientDao.findByCode(patientDevice.getUser());
            if (patient != null) {
                object.put("userName", patient.getName());
            }
            objects.add(object);
        }
        return objects;
    }
    /**
     * 患者设备列表接口(分页)
     */
    public Page<PatientDevice> findByPatient(String patientCode, long id, int pageSize) {
        if (id < 0) {
            id = 0;
        }
        if (pageSize <= 0) {
            pageSize = 10;
        }
        // 排序
        Sort sort = new Sort(Direction.DESC, "id");
        // 分页信息
        PageRequest pageRequest = new PageRequest(0, pageSize, sort);
        // 设置查询条件
        Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
        filters.put("patient", new SearchFilter("user", Operator.EQ, patientCode));
        //filters.put("del", new SearchFilter("del", Operator.EQ, 0));
        if (id > 0) {
            filters.put("id", new SearchFilter("id", Operator.LT, id));
        }
        Specification<PatientDevice> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientDevice.class);
        return patientDeviceDao.findAll(spec, pageRequest);
    }
    /**
     * 患者设备列表接口--医生端
     */
    public List<Map<String, Object>> findByDoctor(String patientCode, String doctorCode, int page, int pagesize) {
        List<Map<String, Object>> re = new ArrayList<>();
        if (page <= 0) {
            page = 1;
        }
        if (pagesize <= 0) {
            pagesize = 10;
        }
        //boolean bo = false;
        ////判断该医生是否属于患者的签约行政团队
        //List<AdminTeamMember> adminTeamMembers = doctorAdminTeamMemberDao.findByAdminTeam(patientCode,doctorCode);
        //if(adminTeamMembers!=null && adminTeamMembers.size()>0)
        //{
        //	bo = true;
        //}
        PageRequest pageRequest = new PageRequest(page - 1, pagesize);
        List<PatientDevice> list = new ArrayList<>();
        //if(bo) //签约医生查看所有设备
        //{
        //	list = patientDeviceDao.findByUser(patientCode,pageRequest);
        //}
        //else{
        //	list = patientDeviceDao.findByUserAndDoctor(patientCode, doctorCode,pageRequest);
        //}
        list = patientDeviceDao.findByUser(patientCode, pageRequest);
        if (list != null) {
            //获取设备路径,医生姓名
            List<Device> deviceList = deviceDao.findAll();
            Doctor self = doctorDao.findByCode(doctorCode);
            for (PatientDevice item : list) {
                Map<String, Object> map = new HashMap<>();
                if (StringUtils.isNotBlank(item.getDoctor())) {
                    if (StringUtils.equals(item.getDoctor(), doctorCode)) {
                        map.put("role", 1);//可解绑自己绑定的
                    } else {
                        List<AdminTeam> adminTeams = adminTeamService.findDoctorsTeams(item.getDoctor(), doctorCode);
                        if (adminTeams != null && adminTeams.size() > 0) {
                            map.put("role", 1);//同行政团队可解绑
                        } else {
                            map.put("role", 0);//不同行政团队不可解绑
                        }
                    }
                } else {
                    map.put("role", 0);//患者自己绑定无法解绑
                }
                map.put("id", item.getId());
                map.put("deviceId", item.getDeviceId());
                map.put("deviceSn", item.getDeviceSn());
                map.put("user", item.getUser());
                map.put("categoryCode", item.getCategoryCode());
                map.put("userType", item.getUserType());
                map.put("userIdcard", item.getUserIdcard());
                map.put("czrq", DateUtil.dateToStrLong(item.getCzrq()));
                String deviceDoctor = item.getDoctor();
                if (deviceDoctor == null) {
                    map.put("doctor", "");
                    map.put("doctorName", "");
                } else {
                    map.put("doctor", deviceDoctor);
                    if (deviceDoctor.equals(doctorCode)) {
                        map.put("doctorName", self.getName());
                    } else {
                        Doctor doctor = doctorDao.findByCode(deviceDoctor);
                        if (doctor != null) {
                            map.put("doctorName", doctor.getName());
                        } else {
                            map.put("doctorName", "");
                        }
                    }
                }
                //获取设备路径
                for (Device de : deviceList) {
                    if (de.getId().equals(item.getDeviceId())) {
                        map.put("deviceName", de.getName());
                        map.put("devicePhoto", de.getPhoto());
                        map.put("deviceBrands", de.getBrands());
                        break;
                    }
                }
                re.add(map);
            }
        }
        re.sort(new Comparator<Map<String, Object>>() {
            @Override
            public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                if (o1.get("czrq").toString().compareTo(o2.get("czrq").toString()) > 0) {
                    return -1;
                }
                if (o1.get("czrq").toString().compareTo(o2.get("czrq").toString()) < 0) {
                    return 1;
                }
                return 0;
            }
        });
        return re;
    }
    /**
     * 查询患者已拥有的设备
     *
     * @param patient
     * @return
     */
    public Iterator<PatientDevice> findPatientHave(String patient) {
        return patientDeviceDao.findByUser(patient).iterator();
    }
    /**
     * 获取患者设备信息
     **/
    public PatientDevice findById(String id) {
        return patientDeviceDao.findOne(Long.valueOf(id));
    }
    /**
     * 通过sn码获取设备绑定情况
     **/
    public List<Map<String, String>> getDeviceUser(String user, String deviceSn, String type) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        List<PatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        if (list != null) {
            for (PatientDevice item : list) {
                Map<String, String> map = new HashMap<>();
                map.put("type", item.getUserType());
                String code = item.getUser();
                if (code.equals(user)) {
                    map.put("others", "0");
                } else {
                    map.put("others", "1");
                }
                //获取姓名
                Patient patient = patientDao.findByCode(code);
                if (patient != null) {
                    map.put("name", patient.getName());
                } else {
                    map.put("name", code);
                }
                re.add(map);
            }
        }
        return re;
    }
    public JSONArray getDeviceByDeviceSn(String deviceSn, String type) {
        List<PatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        JSONArray objects = new JSONArray();
        for (PatientDevice patientDevice : list) {
            JSONObject object = new JSONObject(patientDevice);
            Patient patient = patientDao.findByCode(patientDevice.getUser());
            if (patient != null) {
                object.put("userName", patient.getName());
            }
            objects.put(object);
        }
        return objects;
    }
    /**
     * 获取血糖仪各个时间段(无参为默认时间段)
     *
     * @param user
     * @param deviceSN
     * @return
     */
    public Map getBloodSuggerTime(String user, String deviceSN) {
        Map map = new HashMap();
        PatientBloodSugger bloodSugger = null;
        PatientHealthTime patientHealthTime = null;
        if (StringUtils.isEmpty(user) && StringUtils.isEmpty(deviceSN)) {
            bloodSugger = patientBloodSuggerDao.findRecent();
        } else {
            patientHealthTime = patientHealthTimeDao.findByUserAndSN(user, deviceSN);
        }
        String fastingStart = null;
        String fastingEnd = null;
        String afterBreakFastStart = null;
        String afterBreakFastEnd = null;
        String beforeLunchStart = null;
        String beforeLunchEnd = null;
        String afterLunchStart = null;
        String afterLunchEnd = null;
        String beforeDinnerStart = null;
        String beforeDinnerEnd = null;
        String afterDinnerStart = null;
        String afterDinnerEnd = null;
        String beforeSleepStart = null;
        String beforeSleepEnd = null;
        if (patientHealthTime == null) {
            fastingStart = bloodSugger.getFastingStart();
            fastingEnd = bloodSugger.getFastingEnd();
            afterBreakFastStart = bloodSugger.getAfterBreakfastStart();
            afterBreakFastEnd = bloodSugger.getAfterBreakfastEnd();
            beforeLunchStart = bloodSugger.getBeforeLunchStart();
            beforeLunchEnd = bloodSugger.getBeforeLunchEnd();
            afterLunchStart = bloodSugger.getAfterLunchStart();
            afterLunchEnd = bloodSugger.getAfterLunchEnd();
            beforeDinnerStart = bloodSugger.getBeforeDinnerStart();
            beforeDinnerEnd = bloodSugger.getBeforeDinnerEnd();
            afterDinnerStart = bloodSugger.getAfterDinnerStart();
            afterDinnerEnd = bloodSugger.getAfterDinnerEnd();
            beforeSleepStart = bloodSugger.getBeforeSleepStart();
            beforeSleepEnd = bloodSugger.getBeforeSleepEnd();
        } else {
            fastingStart = patientHealthTime.getFastingStart();
            fastingEnd = patientHealthTime.getFastingEnd();
            afterBreakFastStart = patientHealthTime.getAfterBreakfastStart();
            afterBreakFastEnd = patientHealthTime.getAfterBreakfastEnd();
            beforeLunchStart = patientHealthTime.getBeforeLunchStart();
            beforeLunchEnd = patientHealthTime.getBeforeLunchEnd();
            afterLunchStart = patientHealthTime.getAfterLunchStart();
            afterLunchEnd = patientHealthTime.getAfterLunchEnd();
            beforeDinnerStart = patientHealthTime.getBeforeDinnerStart();
            beforeDinnerEnd = patientHealthTime.getBeforeDinnerEnd();
            afterDinnerStart = patientHealthTime.getAfterDinnerStart();
            afterDinnerEnd = patientHealthTime.getAfterDinnerEnd();
            beforeSleepStart = patientHealthTime.getBeforeSleepStart();
            beforeSleepEnd = patientHealthTime.getBeforeSleepEnd();
        }
        map.put("fasting", fastingStart + " - " + fastingEnd);
        map.put("afterBreakFast", afterBreakFastStart + " - " + afterBreakFastEnd);
        map.put("beforeLunch", beforeLunchStart + " - " + beforeLunchEnd);
        map.put("afterLunch", afterLunchStart + " - " + afterLunchEnd);
        map.put("beforeDinner", beforeDinnerStart + " - " + beforeDinnerEnd);
        map.put("afterDinner", afterDinnerStart + " - " + afterDinnerEnd);
        map.put("beforeSleep", beforeSleepStart + " - " + beforeSleepEnd);
        return map;
    }
    /**
     * 用户自定义血糖仪各个时间段
     *
     * @param fastingStart
     * @param fastingEnd
     * @param afterBreakfastStart
     * @param afterBreakfastEnd
     * @param beforeLunchStart
     * @param beforeLunchEnd
     * @param afterLunchStart
     * @param afterLunchEnd
     * @param beforeDinnerStart
     * @param beforeDinnerEnd
     * @param afterDinnerStart
     * @param afterDinnerEnd
     * @param beforeSleepStart
     * @param beforeSleepEnd
     */
    public void setBloodTime(String user, String deviceSN, String fastingStart, String fastingEnd, String afterBreakfastStart, String afterBreakfastEnd, String beforeLunchStart, String beforeLunchEnd,
                             String afterLunchStart, String afterLunchEnd, String beforeDinnerStart, String beforeDinnerEnd, String afterDinnerStart, String afterDinnerEnd,
                             String beforeSleepStart, String beforeSleepEnd) {
        PatientHealthTime patientHealthTime = new PatientHealthTime();
        patientHealthTime.setUser(user);
        patientHealthTime.setDeviceSN(deviceSN);
        patientHealthTime.setFastingStart(fastingStart);
        patientHealthTime.setFastingEnd(fastingEnd);
        patientHealthTime.setAfterBreakfastStart(afterBreakfastStart);
        patientHealthTime.setAfterBreakfastEnd(afterBreakfastEnd);
        patientHealthTime.setBeforeLunchStart(beforeLunchStart);
        patientHealthTime.setBeforeLunchEnd(beforeLunchEnd);
        patientHealthTime.setAfterLunchStart(afterLunchStart);
        patientHealthTime.setAfterLunchEnd(afterLunchEnd);
        patientHealthTime.setBeforeDinnerStart(beforeDinnerStart);
        patientHealthTime.setBeforeDinnerEnd(beforeDinnerEnd);
        patientHealthTime.setAfterDinnerStart(afterDinnerStart);
        patientHealthTime.setAfterDinnerEnd(afterDinnerEnd);
        patientHealthTime.setBeforeSleepStart(beforeSleepStart);
        patientHealthTime.setBeforeSleepEnd(beforeSleepEnd);
        patientHealthTime.setDel(1);
        patientHealthTime.setCzrq(new Date());
        patientHealthTimeDao.save(patientHealthTime);
    }
}

+ 27 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -70,6 +70,32 @@ public class PatientHealthIndexService extends BaseService {
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    //更改接口(包括手动记录的修改和所有的删除)
    public void modify(long id, String value1, String value2, String value3, String value4) {
        Date time = new Date();
        String sql = "";
//            字段值均为空为删除
        if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
            sql = " update device.wlyy_patient_health_index a set a.del = 0 where a.id =? ";
            jdbcTemplate.update(sql, id);
        }
        sql = " update device.wlyy_patient_health_index a set ";
        if (StringUtils.isNotEmpty(value1)) {
            sql += " a.value1 = " +value1+" , ";
        }
        if (StringUtils.isNotEmpty(value2)) {
            sql +=  " a.value2 = " +value2+" , ";
        }
        if (StringUtils.isNotEmpty(value3)) {
            sql +=  " a.value3 = " +value3+" , ";
        }
        if (StringUtils.isNotEmpty(value4)) {
            sql += " a.value4 = " +value4+", ";
        }
         sql += " a.czrq = ?  where a.device_sn is null and a.id =? ";
        jdbcTemplate.update(sql, time, id);
    }
    /**
     * 获取居民最新各类健康记录
     */
@ -78,7 +104,7 @@ public class PatientHealthIndexService extends BaseService {
        String sql = "SELECT " +
                " a.* " +
                " FROM " +
                "  wlyy_patient_health_index a " +
                "  device.wlyy_patient_health_index a " +
                " WHERE " +
                " a. USER = ? " +
                " AND a.type = ? " +

+ 137 - 96
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -16,123 +16,164 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 患者端:设备管理控制类
 * @author George
 *
 * @author George
 */
@Controller
@RequestMapping(value = "patient/device")
@Api(value = "患者设备管理", description = "患者设备管理")
public class PatientDeviceController extends BaseController {
	@Autowired
	private PatientDeviceService patientDeviceService;
    @Autowired
    private PatientDeviceService patientDeviceService;
	private ObjectMapper  objectMapper=new ObjectMapper();
    private ObjectMapper objectMapper = new ObjectMapper();
	/**
	 * 设备保存接口
	 */
	@ApiOperation("设备保存接口")
	@RequestMapping(value = "SavePatientDevice",method = RequestMethod.POST)
	@ResponseBody
	public String saveDevice(@ApiParam(name="json",value="设备数据json",defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"7052169111\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
							  @RequestParam(value="json",required = true) String json) {
		try {
			PatientDevice device = objectMapper.readValue(json,PatientDevice.class);
			// 设置患者标识
			device.setUser(getUID());
			patientDeviceService.saveDevice(device);
    /**
     * 设置血糖仪时间段
     * 默认时间段如下
     * fasting: 00:00-07:59
     * afterBreakfast: 08:00-09:59
     * beforeLunch: 10:00-11:59
     * afterLunch: 12:00-13:59
     * beforeDinner: 14:00-17:59
     * afterDinner: 18:00-19:59
     * beforeSleep: 20:00-23:59
     */
    @ApiOperation("设置血糖仪时间段")
    @RequestMapping(value = "/setBloodTime", method = RequestMethod.GET)
    @ResponseBody
    public String setBloodTime(@RequestParam String fastingStart,
                               @RequestParam String fastingEnd,
                               @RequestParam String afterBreakfastStart,
                               @RequestParam String afterBreakfastEnd,
                               @RequestParam String beforeLunchStart,
                               @RequestParam String beforeLunchEnd,
                               @RequestParam String afterLunchStart,
                               @RequestParam String afterLunchEnd,
                               @RequestParam String beforeDinnerStart,
                               @RequestParam String beforeDinnerEnd,
                               @RequestParam String afterDinnerStart,
                               @RequestParam String afterDinnerEnd,
                               @RequestParam String beforeSleepStart,
                               @RequestParam String beforeSleepEnd,
                               @RequestParam String deviceSN) {
        String user = getUID();
        patientDeviceService.setBloodTime(user,deviceSN,fastingStart,fastingEnd,afterBreakfastStart,afterBreakfastEnd,beforeLunchStart,beforeLunchEnd,
                afterLunchStart,afterLunchEnd,beforeDinnerStart,beforeDinnerEnd,afterDinnerStart,afterDinnerEnd,beforeSleepStart,beforeSleepEnd);
        return null;
    }
			return success("设备保存成功!");
		}
		catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    /**
     * 设备保存接口  ---要增加血糖时间段保存
     */
    @ApiOperation("设备保存接口")
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    @ResponseBody
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"7052169111\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
                             @RequestParam(value = "json", required = true) String json) {
        try {
            PatientDevice device = objectMapper.readValue(json, PatientDevice.class);
            // 设置患者标识
            device.setUser(getUID());
	/**
	 *  设备列表获取
	 * @return 操作结果
	 */
	@ApiOperation("患者设备列表获取")
	@RequestMapping(value = "PatientDeviceList",method = RequestMethod.GET)
	@ResponseBody
	public String getDeviceByPatient(@ApiParam(name="id",value="分页起始id",defaultValue = "0")
									  @RequestParam(value="id",required = true) long id,
									 @ApiParam(name="pagesize",value="每页条数",defaultValue = "10")
									 @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
			Page<PatientDevice> list = patientDeviceService.findByPatient(getUID(), id, pagesize);
            patientDeviceService.saveDevice(device);
			return write(200, "查询成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
            return success("设备保存成功!");
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    /**
     * 设备列表获取
     *
     * @return 操作结果
     */
    @ApiOperation("患者设备列表获取")
    @RequestMapping(value = "PatientDeviceList", method = RequestMethod.GET)
    @ResponseBody
    public String getDeviceByPatient(@ApiParam(name = "id", value = "分页起始id", defaultValue = "0")
                                     @RequestParam(value = "id", required = true) long id,
                                     @ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
                                     @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            Page<PatientDevice> list = patientDeviceService.findByPatient(getUID(), id, pagesize);
	@ApiOperation("获取患者设备信息")
	@RequestMapping(value = "PatientDeviceInfo",method = RequestMethod.GET)
	@ResponseBody
	public String getPatientDeviceInfo(@ApiParam(name="id",value="患者设备ID",defaultValue = "146")
									 @RequestParam(value="id",required = true) String id) {
		try {
			PatientDevice device = patientDeviceService.findById(id);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
			return write(200, "查询成功", "data", device);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    //要增加时间段信息展示
    @ApiOperation("获取患者设备信息")
    @RequestMapping(value = "PatientDeviceInfo", method = RequestMethod.GET)
    @ResponseBody
    public String getPatientDeviceInfo(@ApiParam(name = "id", value = "患者设备ID", defaultValue = "146")
                                       @RequestParam(value = "id", required = true) String id) {
        try {
            Map mapList = new HashMap();
            PatientDevice device = patientDeviceService.findById(id);
            String deviceSN = device.getDeviceSn();
            String user = device.getUser();
            Map map = patientDeviceService.getBloodSuggerTime(user,deviceSN);
            mapList.put("time",map);
            mapList.put("device",device);
            return write(200, "查询成功", "data", mapList);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
	/**
	 *  通过sn码获取设备绑定情况
	 */
	@ApiOperation("通过sn码获取设备绑定情况")
	@RequestMapping(value = "PatientDeviceIdcard",method = RequestMethod.GET)
	@ResponseBody
	public String getDeviceUser(@ApiParam(name="type",value="设备类型",defaultValue = "1")
									     @RequestParam(value="type",required = true) String type,
										 @ApiParam(name="device_sn",value="设备SN码",defaultValue = "15L000002")
										 @RequestParam(value="device_sn",required = true) String deviceSn) {
		try {
			List<Map<String,String>> list = patientDeviceService.getDeviceUser(getUID(),deviceSn,type);
			return write(200, "获取设备绑定信息成功!", "data",list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
    /**
     * 通过sn码获取设备绑定情况
     */
    @ApiOperation("通过sn码获取设备绑定情况")
    @RequestMapping(value = "PatientDeviceIdcard", method = RequestMethod.GET)
    @ResponseBody
    public String getDeviceUser(@ApiParam(name = "type", value = "设备类型", defaultValue = "1")
                                @RequestParam(value = "type", required = true) String type,
                                @ApiParam(name = "device_sn", value = "设备SN码", defaultValue = "15L000002")
                                @RequestParam(value = "device_sn", required = true) String deviceSn) {
        try {
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getUID(), deviceSn, type);
            return write(200, "获取设备绑定信息成功!", "data", list);
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
	/**
	 * 设备删除
	 */
	@ApiOperation("设备删除")
	@RequestMapping(value = "DeletePatientDevice")
	@ResponseBody
	public String delete(@ApiParam(name="id",value="删除设备关联ID")
						  @RequestParam(value="id",required = true) String id) {
		try {
			PatientDevice pd = patientDeviceService.findById(id);
			if(pd!=null)
			{
				if (!StringUtils.equals(pd.getUser(), getUID())) {
					return error(-1, "只允许删除自己的设备!");
				}
				// 删除设备
				patientDeviceService.deleteDevice(id,getUID());
				return success("设备已删除!");
			}
			else{
				return error(-1, "不存在该设备!");
			}
		} catch (Exception ex) {
			return invalidUserException(ex, -1,ex.getMessage());
		}
	}
    /**
     * 设备删除
     */
    @ApiOperation("设备删除")
    @RequestMapping(value = "DeletePatientDevice")
    @ResponseBody
    public String delete(@ApiParam(name = "id", value = "删除设备关联ID")
                         @RequestParam(value = "id", required = true) String id) {
        try {
            PatientDevice pd = patientDeviceService.findById(id);
            if (pd != null) {
                if (!StringUtils.equals(pd.getUser(), getUID())) {
                    return error(-1, "只允许删除自己的设备!");
                }
                // 删除设备
                patientDeviceService.deleteDevice(id, getUID());
                return success("设备已删除!");
            } else {
                return error(-1, "不存在该设备!");
            }
        } catch (Exception ex) {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
}

+ 60 - 39
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -31,6 +32,33 @@ public class PatientHealthController extends BaseController {
    @Autowired
    private PatientHealthIndexService healthIndexService;
    /**
     * 更改接口(包括手动记录的修改和所有的删除)
     * 血糖  value1 血糖值 value2 1234567血糖时间段
     * 血压  value1 高压 value2 低压 value3脉搏 value4心率不齐(0否 1是)
     * 体重 value1 体重值
     * 腰围 value1 腰围值
     * @param id
     * @param value1 字段值
     * @return
     */
    @RequestMapping(value = "/modify", method = RequestMethod.GET)
    @ResponseBody
    public String modify(@RequestParam long id,
                         @RequestParam(required = false) String value1,
                         @RequestParam(required = false) String value2,
                         @RequestParam(required = false) String value3,
                         @RequestParam(required = false) String value4) {
        try {
            healthIndexService.modify(id,value1,value2,value3,value4);
            return write(200, "更改成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "更改失败!");
        }
    }
    /**
     * 患者最近的各项健康信息
     *
@ -42,14 +70,13 @@ public class PatientHealthController extends BaseController {
        try {
            List list = new ArrayList();
            String patient = getUID();
//            String patient = "test_4429a0a4138a281e7c6316eb9bd";
//            健康指标类型(1血糖,2血压,3体重,4腰围)
            Map map = healthIndexService.findDataByPatient(patient, 1);
            Map map1 = healthIndexService.findDataByPatient(patient, 2);
            Map map2 = healthIndexService.findDataByPatient(patient, 3);
            Map map3 = healthIndexService.findDataByPatient(patient, 4);
//            血糖各个时间段取值
            if (map.size()!=0) {
            if (map.size() != 0) {
                Map sugar = new HashMap();
                Object time = map.get("time");
                String isDevice = map.get("isDevice").toString();
@ -62,40 +89,34 @@ public class PatientHealthController extends BaseController {
                Object value7 = map.get("value7");
                sugar.put("type", 1);
                sugar.put("isDevice", isDevice);
                if (time!=null){
                if (time != null) {
                    sugar.put("time", time);
                }
                if (value1 != null) {
                    sugar.put("value1", value1);
                }
                if (value2!=null) {
                    sugar.remove("value1");
                if (value2 != null) {
                    sugar.put("value2", value2);
                }
                if (value3!=null) {
                    sugar.remove("value2");
                if (value3 != null) {
                    sugar.put("value3", value3);
                }
                if (value4!=null) {
                    sugar.remove("value3");
                if (value4 != null) {
                    sugar.put("value4", value4);
                }
                if (value5!=null) {
                    sugar.remove("value4");
                if (value5 != null) {
                    sugar.put("value5", value5);
                }
                if (value6!=null) {
                    sugar.remove("value5");
                if (value6 != null) {
                    sugar.put("value6", value6);
                }
                if (value7!=null) {
                    sugar.remove("value6");
                if (value7 != null) {
                    sugar.put("value7", value7);
                }
                list.add(sugar);
            }
//            血压  value1高压 value2低压 value3脉搏 value4心率不齐
            if (map1.size()!=0) {
            if (map1.size() != 0) {
                Map pa = new HashMap();
                Object time = map1.get("time");
                String isDevice = map1.get("isDevice").toString();
@ -108,34 +129,34 @@ public class PatientHealthController extends BaseController {
                Object value7 = map1.get("value7");
                pa.put("type", 2);
                pa.put("isDevice", isDevice);
                if (time!=null){
                if (time != null) {
                    pa.put("time", time);
                }
                if (value1 != null) {
                    pa.put("value1", value1);
                }
                if (value2!=null) {
                if (value2 != null) {
                    pa.put("value2", value2);
                }
                if (value3!=null) {
                if (value3 != null) {
                    pa.put("value3", value3);
                }
                if (value4!=null) {
                if (value4 != null) {
                    pa.put("value4", value4);
                }
                if (value5!=null) {
                if (value5 != null) {
                    pa.put("value5", value5);
                }
                if (value6!=null) {
                if (value6 != null) {
                    pa.put("value6", value6);
                }
                if (value7!=null) {
                if (value7 != null) {
                    pa.put("value7", value7);
                }
                list.add(pa);
            }
//            体重 value1 体重
            if (map2.size()!=0) {
            if (map2.size() != 0) {
                Map weight = new HashMap();
                Object time = map2.get("time");
                String isDevice = map2.get("isDevice").toString();
@ -148,34 +169,34 @@ public class PatientHealthController extends BaseController {
                Object value7 = map2.get("value7");
                weight.put("type", 3);
                weight.put("isDevice", isDevice);
                if (time!=null){
                if (time != null) {
                    weight.put("time", time);
                }
                if (value1 != null) {
                    weight.put("value1", value1);
                }
                if (value2!=null) {
                if (value2 != null) {
                    weight.put("value2", value2);
                }
                if (value3!=null) {
                if (value3 != null) {
                    weight.put("value3", value3);
                }
                if (value4!=null) {
                if (value4 != null) {
                    weight.put("value4", value4);
                }
                if (value5!=null) {
                if (value5 != null) {
                    weight.put("value5", value5);
                }
                if (value6!=null) {
                if (value6 != null) {
                    weight.put("value6", value6);
                }
                if (value7!=null) {
                if (value7 != null) {
                    weight.put("value7", value7);
                }
                list.add(weight);
            }
//            腰围 value1腰围
            if (map3.size()!=0) {
            if (map3.size() != 0) {
                Map waist = new HashMap();
                Object time = map3.get("time");
                String isDevice = map3.get("isDevice").toString();
@ -188,28 +209,28 @@ public class PatientHealthController extends BaseController {
                Object value7 = map3.get("value7");
                waist.put("type", 4);
                waist.put("isDevice", isDevice);
                if (time!=null){
                if (time != null) {
                    waist.put("time", time);
                }
                if (value1 != null) {
                    waist.put("value1", value1);
                }
                if (value2!=null) {
                if (value2 != null) {
                    waist.put("value2", value2);
                }
                if (value3!=null) {
                if (value3 != null) {
                    waist.put("value3", value3);
                }
                if (value4!=null) {
                if (value4 != null) {
                    waist.put("value4", value4);
                }
                if (value5!=null) {
                if (value5 != null) {
                    waist.put("value5", value5);
                }
                if (value6!=null) {
                if (value6 != null) {
                    waist.put("value6", value6);
                }
                if (value7!=null) {
                if (value7 != null) {
                    waist.put("value7", value7);
                }
                list.add(waist);