浏览代码

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

trick9191 8 年之前
父节点
当前提交
ca05283745
共有 19 个文件被更改,包括 1481 次插入667 次删除
  1. 226 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientBloodSugger.java
  2. 248 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientHealthTime.java
  3. 27 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/feedback/Appeal.java
  4. 46 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/feedback/Feedback.java
  5. 61 59
      patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java
  6. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  7. 11 10
      patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  8. 14 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/PatientBloodSuggerDao.java
  9. 18 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/PatientHealthTimeDao.java
  10. 489 386
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  11. 29 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/AppealService.java
  12. 27 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/FeedbackService.java
  13. 27 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  14. 6 27
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackController.java
  15. 8 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  16. 38 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthRecordController.java
  17. 137 96
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  18. 6 26
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientFeedbackController.java
  19. 60 39
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java

+ 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;
    }
}

+ 27 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/feedback/Appeal.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.entity.feedback;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -30,9 +31,32 @@ public class Appeal extends IdEntity {
    //    申诉人身份:1、患者  2、医生
    private int identity;
    //是否删除   0 删除    1.未删除
    private Integer del ;
    @Column(name="creater_name")
    private String createrName;
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getCreaterName() {
        return createrName;
    }
    public void setCreaterName(String createrName) {
        this.createrName = createrName;
    }
    public Appeal() {
    }
    public Appeal(String code, String creater, String description, int type, String images, String phone, int status, String result, int identity) {
    public Appeal(String code, String creater, String description, int type, String images, String phone, int status, String result, int identity, Integer del, String createrName) {
        this.code = code;
        this.creater = creater;
        this.description = description;
@ -42,6 +66,8 @@ public class Appeal extends IdEntity {
        this.status = status;
        this.result = result;
        this.identity = identity;
        this.del = del;
        this.createrName = createrName;
    }
    public String getCode() {

+ 46 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/feedback/Feedback.java

@ -1,8 +1,8 @@
package com.yihu.wlyy.entity.feedback;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.*;
/**
 * Created by Reece on 2017/5/6.
@ -10,24 +10,64 @@ import javax.persistence.Table;
@Entity
@Table(name = "wlyy_feedback")
public class Feedback extends IdEntity{
//    意见反馈编码
    @Column(name="code")
    private String code;
//    反馈人编码
    @Column(name="creater")
    private String creater;
//    反馈人身份 1、患者  2、医生
    @Column(name="identity")
    private  int identity;
//    问题描述
    @Column(name="description")
    private String description;
//    反馈类别:1、优化建议、2、提交bug、3、新功能建议、4、其他
    @Column(name="type")
    private int type;
//    图片路径,逗号分隔
    @Column(name="images")
    private String images;
//    联系方式: qq号或者邮箱
    @Column(name="contact")
    private String contact;
//    状态 0、未读 1、已读
    @Column(name="status")
    private int status;
    public Feedback(String code, String creater, int identity, String description, int type, String images, String contact, int status) {
    //逻辑删除 0.删除   1.正常
    @Column(name="del")
    private Integer del;
    //创建人名字
    @Column(name="creater_name")
    private String createrName;
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getCreaterName() {
        return createrName;
    }
    public void setCreaterName(String createrName) {
        this.createrName = createrName;
    }
    public Feedback(String code, String creater, int identity, String description, int type, String images, String contact, int status, Integer del, String createrName) {
        this.code = code;
        this.creater = creater;
        this.identity = identity;
@ -36,7 +76,10 @@ public class Feedback extends IdEntity{
        this.images = images;
        this.contact = contact;
        this.status = status;
        this.del = del;
        this.createrName = createrName;
    }
    public Feedback() {
    }

+ 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);
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -138,6 +138,9 @@ public class DoctorInterceptor extends BaseInterceptor {
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if(null==request.getAttribute("log-start")){
            return;
        }
        long start = (long) request.getAttribute("log-start");
        long end = new Date().getTime();
        Class cls = ((HandlerMethod) handler).getBeanType();

+ 11 - 10
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -1,22 +1,20 @@
package com.yihu.wlyy.interceptors;
import java.lang.reflect.Method;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.logs.InterfaceCallLogs;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.ModelAndView;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Date;
/**
 * 患者权限校验
@ -98,6 +96,9 @@ public class PatientInterceptor extends BaseInterceptor {
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		if(null==request.getAttribute("log-start")){
			return;
		}
		long start = (long) request.getAttribute("log-start");
		long end = new Date().getTime();
		Class cls = ((HandlerMethod) handler).getBeanType();

+ 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);
    }
}

+ 29 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/AppealService.java

@ -1,8 +1,12 @@
package com.yihu.wlyy.service.app.feedback;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.feedback.Appeal;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.feedback.AppealDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -16,15 +20,35 @@ public class AppealService extends BaseService {
    @Autowired
    private AppealDao appealDao;
    public void saveAppeal(String doctor,String description,int type,String images,String phone,int identity) throws Exception{
    @Autowired
    private PatientService patientService;
    @Autowired
    private DoctorService doctorService;
    public void saveAppeal(String creater,String description,int type,String images,String phone,int identity) throws Exception{
        Appeal appeal = new Appeal();
        appeal.setCode(getCode());
        appeal.setPhone(phone);
        appeal.setCreater(doctor);
        appeal.setCreater(creater);
        appeal.setDescription(description);
        appeal.setIdentity(identity);
        appeal.setImages(images);
        appeal.setType(type);
        appeal.setImages(images);
        appeal.setPhone(phone);
        appeal.setStatus(0);
        appeal.setIdentity(identity);
        appeal.setDel(1);
        //通过creater获取创建人名字
        String name ="";
        if(creater!=null&&!"".equals(creater)){
            if(identity==1){//说明是患者
                Patient patient = patientService.findByCode(creater);
                name = patient.getName();
            }else{//说明是医生
                Doctor doctor = doctorService.findDoctorByCode(creater);
                name = doctor.getName();
            }
        }
        appeal.setCreaterName(name);
        appealDao.save(appeal);
    }
}

+ 27 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/feedback/FeedbackService.java

@ -1,8 +1,12 @@
package com.yihu.wlyy.service.app.feedback;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.feedback.Feedback;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.feedback.FeedbackDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -16,15 +20,33 @@ public class FeedbackService extends BaseService {
    @Autowired
    private FeedbackDao feedbackDao;
    public void saveFeedback(String doctor,String description,int type,String images,String contact,int idetity) throws Exception{
    @Autowired
    private PatientService patientService;
    @Autowired
    private DoctorService doctorService;
    public void saveFeedback(String creater,int identity,String description,int type,String images,String contact) throws Exception{
        Feedback feedback = new Feedback();
        feedback.setCode(getCode());
        feedback.setContact(contact);
        feedback.setCreater(doctor);
        feedback.setCreater(creater);
        feedback.setIdentity(identity);
        feedback.setDescription(description);
        feedback.setIdentity(idetity);
        feedback.setImages(images);
        feedback.setType(type);
        feedback.setImages(images);
        feedback.setContact(contact);
        feedback.setStatus(0);
        feedback.setDel(1);
        //通过creater获取创建人名字
        String name ="";
        if(identity==1){//说明是患者
            Patient patient = patientService.findByCode(creater);
            name = patient.getName();
        }else{//说明是医生
            Doctor doctor = doctorService.findDoctorByCode(creater);
            name = doctor.getName();
        }
        feedback.setCreaterName(name);
        feedbackDao.save(feedback);
    }

+ 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 = ? " +

+ 6 - 27
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/feedback/DoctorFeedbackController.java

@ -14,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.regex.Pattern;
/**
 * Created by Reece on 2017/5/6.
 */
@ -46,24 +44,12 @@ public class DoctorFeedbackController extends BaseController {
            @RequestParam(required = false) String images,
            @RequestParam(required = false) String contact) {
        try {
            if (StringUtils.isNotEmpty(contact)) {
                //        邮箱正则|QQ号|手机号正则
                String regexEmail = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
                String regexQQ = "^[1-9][0-9]{4,}$";
                String regexPhone = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
                Boolean emailFlag = Pattern.matches(regexEmail, contact);
                Boolean qqFlag = Pattern.matches(regexQQ, contact);
                Boolean phoneFlag = Pattern.matches(regexPhone, contact);
                if (emailFlag || qqFlag || phoneFlag) {
                    return write(-1, "QQ/邮箱格式错误!");
                }
            }
//        图片上传
            if (StringUtils.isNotEmpty(images)) {
                images = CommonUtil.copyTempImage(images);
            }
//        保存到数据库
            feedbackService.saveFeedback(getUID(),description,type,images,contact,2);
            feedbackService.saveFeedback(getUID(),2,description,type,images,contact);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
@ -89,20 +75,13 @@ public class DoctorFeedbackController extends BaseController {
            @RequestParam(required = false) String images,
            @RequestParam String phone) {
        try {
//        手机号正则
            String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
            if (Pattern.matches(regex, phone)) {
//        图片上传
                if (StringUtils.isNotEmpty(images)) {
                    images = CommonUtil.copyTempImage(images);
                }
//             保存到数据库
                appealService.saveAppeal(getUID(),description,type,images,phone,2);
                return write(200, "保存成功!");
            } else {
                return write(-1, "手机号码有误!");
            if (StringUtils.isNotEmpty(images)) {
                images = CommonUtil.copyTempImage(images);
            }
//             保存到数据库
            appealService.saveAppeal(getUID(),description,type,images,phone,2);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存失败!");

+ 8 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -273,7 +273,14 @@ public class DoctorHealthController extends BaseController {
			{
				map.put("xy",xy);
			}
			DevicePatientHealthIndex tz = healthIndexService.findLastByPatien(patient,3);
			if(tz != null){
				map.put("tz",tz);
			}
			DevicePatientHealthIndex sg = healthIndexService.findLastByPatien(patient,4);
			if(sg != null){
				map.put("sg",sg);
			}
			return write(200, "查询成功", "data", map);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());

+ 38 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthRecordController.java

@ -48,7 +48,9 @@ public class DoctorHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "recent")
	@ResponseBody
	public String recent(String patient) {
	@ApiOperation("根据患者标志获取最近的保健记录")
	public String recent(@ApiParam(name="patient",value="患者代码",defaultValue = "P20160901001")
									 @RequestParam(value="patient",required = true) String patient) {
		try {
			JSONObject json = patientHealthRecordService.findRecentByPatient(patient);
			if (json != null) {
@ -70,7 +72,17 @@ public class DoctorHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_sports")
	@ResponseBody
	public String sports(String patient, String start,String end,int page, int pagesize) {
	@ApiOperation("获取患者运动记录")
	public String sports(@ApiParam(name="patient",value="患者代码",defaultValue = "P20160901001")
							 @RequestParam(value="patient",required = true)String patient,
						 @ApiParam(name="start",value="开始时间",defaultValue = "2017-05-15 00:00:00")
						 @RequestParam(value="start",required = true)String start,
						 @ApiParam(name="end",value="结束时间",defaultValue = "2017-05-15 12:00:00")
							 @RequestParam(value="end",required = true) String end,
						 @ApiParam(name="page",value="第几页",defaultValue = "1")
							 @RequestParam(value="page",required = true) int page,
						 @ApiParam(name="pagesize",value="每页记录数",defaultValue = "10")
							 @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
			//Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatient(patient, DateUtil.strToDateLong(sortDate), pagesize);
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(patient, start,end,page, pagesize);
@ -113,10 +125,19 @@ public class DoctorHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_medication")
	@ResponseBody
	public String medication(String patient, @RequestParam(required = false) String start,
							 @RequestParam(required = false) String end,
							 @RequestParam(required = false) Integer page,
							 @RequestParam(required = false) String sortDate, int pagesize) {
	@ApiOperation("获取患者用药记录")
	public String medication(@ApiParam(name="patient",value="患者代码",defaultValue = "P20160901001")
								 @RequestParam(value="patient",required = true)String patient,
							 @ApiParam(name="start",value="开始")
							 	 @RequestParam(required = true) String start,
							 @ApiParam(name="end",value="结束")
								 @RequestParam(required = false) String end,
							 @ApiParam(name="page",value="第几页",defaultValue = "1")
								 @RequestParam(required = true) Integer page,
							 @ApiParam(name="sortDate",value="日期")
							 	@RequestParam(required = false) String sortDate,
							 @ApiParam(name="pagesize",value="每页记录数",defaultValue = "10")
								 @RequestParam(required = true)int pagesize) {
		try {
			Page<PatientHealthRecordMedication> data = null;
			if(!StringUtils.isEmpty(sortDate)) {
@ -161,7 +182,16 @@ public class DoctorHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_diet")
	@ResponseBody
	public String diet(String patient, String start,String end,int page, int pagesize) {
	public String diet(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
						   @RequestParam(value="patient",required = true)String patient,
					   @ApiParam(name="start",value="开始")
					   @RequestParam(required = true) String start,
					   @ApiParam(name="end",value="结束")
						   @RequestParam(required = false) String end,
					   @ApiParam(name="page",value="第几页",defaultValue = "1")
						   @RequestParam(required = true)int page,
					   @ApiParam(name="pagesize",value="每页记录数",defaultValue = "10")
						   @RequestParam(required = true)int pagesize) {
		try {
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(patient, start,end, page, pagesize);
			if (data != null) {
@ -196,7 +226,7 @@ public class DoctorHealthRecordController extends BaseController {
	@RequestMapping(value = "list_medical", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("查询居民健康体检列表")
	public String medical(@ApiParam(name = "patient", value = "患者代码", defaultValue = "b7ed0275638e11e69616fa163e424525")
	public String medical(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
						    @RequestParam(value="patient",required = true) String patient ,
						    @ApiParam(name = "pageIndex", value = "第几页", defaultValue = "")
						    @RequestParam(value = "pageIndex", required = false) Integer pageIndex,

+ 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());
        }
    }
}

+ 6 - 26
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/feedback/PatientFeedbackController.java

@ -14,8 +14,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.regex.Pattern;
/**
 * Created by Reece on 2017/5/6.
 */
@ -46,25 +44,13 @@ public class PatientFeedbackController extends BaseController {
            @RequestParam(required = false) String images,
            @RequestParam(required = false) String contact) {
        try {
            if (StringUtils.isNotEmpty(contact)) {
                //        邮箱正则|QQ号正则|手机号正则
                String regexEmail = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
                String regexQQ = "^[1-9][0-9]{4,}$";
                String regexPhone = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
                Boolean emailFlag = Pattern.matches(regexEmail, contact);
                Boolean qqFlag = Pattern.matches(regexQQ, contact);
                Boolean phoneFlag = Pattern.matches(regexPhone, contact);
                if (emailFlag || qqFlag || phoneFlag) {
                    return write(-1, "QQ/邮箱/手机号格式错误!");
                }
            }
//        图片上传
            if (StringUtils.isNotEmpty(images)) {
                images = CommonUtil.copyTempImage(images);
            }
//        保存到数据库
            feedbackService.saveFeedback(getUID(),description,type,images,contact,1);
            feedbackService.saveFeedback(getUID(),1,description,type,images,contact);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
@ -90,19 +76,13 @@ public class PatientFeedbackController extends BaseController {
            @RequestParam(required = false) String images,
            @RequestParam String phone) {
        try {
//        手机号正则
            String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$";
            if (Pattern.matches(regex, phone)) {
//        图片上传
                if (StringUtils.isNotEmpty(images)) {
                    images = CommonUtil.copyTempImage(images);
                }
//             保存到数据库
                appealService.saveAppeal(getUID(),description,type,images,phone,1);
                return write(200, "保存成功!");
            } else {
                return write(-1, "手机号码有误!");
            if (StringUtils.isNotEmpty(images)) {
                images = CommonUtil.copyTempImage(images);
            }
//             保存到数据库
            appealService.saveAppeal(getUID(),description,type,images,phone,1);
            return write(200, "保存成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存失败!");

+ 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);