浏览代码

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

hzp 8 年之前
父节点
当前提交
41f7436e38
共有 30 个文件被更改,包括 1477 次插入185 次删除
  1. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/Consult.java
  2. 11 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticlePatient.java
  3. 11 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java
  4. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/message/Message.java
  5. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientHealthGuidance.java
  6. 479 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyRenew.java
  7. 4 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/job/SignEndJob.java
  8. 4 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java
  9. 0 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/deviece/PatientHealthTimeDao.java
  10. 12 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/HealthEduArticlePatientDao.java
  11. 33 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java
  12. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  13. 5 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java
  14. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  15. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  16. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java
  17. 5 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java
  18. 99 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  19. 299 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  20. 70 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  21. 9 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  22. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  23. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  24. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  25. 165 14
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  26. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  27. 10 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  28. 165 138
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java
  29. 44 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  30. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/Consult.java

@ -43,6 +43,8 @@ public class Consult extends IdEntity {
	private String del;
	// 结束时间
	private Date endTime;
	//签约表Code
	private String  signCode;
	public String getCode() {
		return code;
@ -124,4 +126,12 @@ public class Consult extends IdEntity {
	public void setGuidance(Long guidance) {
		this.guidance = guidance;
	}
	public String getSignCode() {
		return signCode;
	}
	public void setSignCode(String signCode) {
		this.signCode = signCode;
	}
}

+ 11 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/HealthEduArticlePatient.java

@ -53,6 +53,9 @@ public class HealthEduArticlePatient extends IdEntity {
	//批次号记录发送所属批次
	private String batchNo;
	//签约表code
	private String signCode;
	public String getBatchNo() {
		return batchNo;
	}
@ -167,4 +170,12 @@ public class HealthEduArticlePatient extends IdEntity {
	public void setSummary(String summary) {
		this.summary = summary;
	}
	public String getSignCode() {
		return signCode;
	}
	public void setSignCode(String signCode) {
		this.signCode = signCode;
	}
}

+ 11 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java

@ -62,6 +62,9 @@ public class Followup extends IdEntity {
	// 行政团队
	private Long adminTeamCode;
	//签约表Code
	private String signCode;
	public Date getFollowupPlanDate() {
		return followupPlanDate;
	}
@ -241,4 +244,12 @@ public class Followup extends IdEntity {
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
	public String getSignCode() {
		return signCode;
	}
	public void setSignCode(String signCode) {
		this.signCode = signCode;
	}
}

文件差异内容过多而无法显示
+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/message/Message.java


+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientHealthGuidance.java

@ -44,6 +44,8 @@ public class PatientHealthGuidance extends IdEntity {
	private int readStatus;
//	指导创建时间
	private Date createTime;
	//签约表Code
	private String signCode;
	public Date getCreateTime() {
		return createTime;
@ -133,4 +135,12 @@ public class PatientHealthGuidance extends IdEntity {
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
	public String getSignCode() {
		return signCode;
	}
	public void setSignCode(String signCode) {
		this.signCode = signCode;
	}
}

+ 479 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyRenew.java

@ -0,0 +1,479 @@
package com.yihu.wlyy.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 家庭签约
 *
 * @author George
 */
@Entity
@Table(name = "wlyy_sign_family_renew")
public class SignFamilyRenew extends IdEntity {
    private static final long serialVersionUID = 364799142991631092L;
    private String code;        // 签约标识
    private String lwCode;      // 两网标识
    private Integer type;       // 签约类型:1三师签约,2网络签约
    private String patient;     // 患者标识
    private String openid;      // 微信OPENID
    private String name;        // 患者姓名
    private String idcard;      // 身份证号
    private String ssc;         // 社保卡号
    private String mobile;      // 手机号
    private String emerMobile;  // 紧急联系人手机号
    private String hospital;    // 签约医院标识
    private String hospitalName;    // 签约医院名称
    private String doctor;      // 全科医生
    private String doctorName;  // 全科医生姓名
    private String doctorHealth;    // 健康管理师
    private String doctorHealthName;    // 健康管理师姓名
    private Date begin;         // 签约开始日期
    private Date end;           // 签约结束日期
    private Integer status;     // 签约状态(-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约
    private String images;      // 签约图片附件URL,多图以逗号分隔
    private String reason;      // 解约原因
    private Date czrq;          // 操作时间
    private String teamCode;
    private Date applyDate;     //签约时间
    private Date applyUnsignDate;//解约时间
    private Date patientApplyDate;//患者发起签约时间
    private Date patientApplyUnsignDate;//患者发起解约时间
    private String signType;//1 用户自己申请  2医生手工带签  3.医生发起邀请
    private String familyCode;//签约code
    private Double expenses;//签约费用
    private String expensesStatus;//扣费状态【0未扣费 1已扣费 2已退费】
    private String signSource;// 签约来源【1 社区签约 2 移动签约】
    private String signDoctorCode;//簽約人code
    private String signDoctorName;//簽約人銘
    private String signDoctorLevel;//簽約人等级
    private String expensesType;//补贴类型(4种类型:01无补贴,02全部贴,03补个人承担部分(20),04补统筹基金(70))
    private String signYear;//签约年度
    private String medicalInsuranceNum;//医保流水号
    private String agentDoctorCode;//代理簽約人code
    private String agentDoctorName;//代理簽約人銘
    private String agentDoctorLevel;//代理簽約人等级
    private Long adminTeamId;//行政团队ID
    private Date expensesTime;//缴费时间
    private Integer isValid;//是否生效
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getLwCode() {
        return lwCode;
    }
    public void setLwCode(String lwCode) {
        this.lwCode = lwCode;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "emer_mobile")
    public String getEmerMobile() {
        return emerMobile;
    }
    public void setEmerMobile(String emerMobile) {
        this.emerMobile = emerMobile;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "doctor_health")
    public String getDoctorHealth() {
        return doctorHealth;
    }
    public void setDoctorHealth(String doctorHealth) {
        this.doctorHealth = doctorHealth;
    }
    @Column(name = "doctor_health_name")
    public String getDoctorHealthName() {
        return doctorHealthName;
    }
    public void setDoctorHealthName(String doctorHealthName) {
        this.doctorHealthName = doctorHealthName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    public Date getBegin() {
        return begin;
    }
    public void setBegin(Date begin) {
        this.begin = begin;
    }
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    public Date getEnd() {
        return end;
    }
    public void setEnd(Date end) {
        this.end = end;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getImages() {
        return images;
    }
    public void setImages(String images) {
        this.images = images;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    @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;
    }
    @Column(name = "team_code")
    public String getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
    @Column(name = "sign_type")
    public String getSignType() {
        return signType;
    }
    public void setSignType(String signType) {
        this.signType = signType;
    }
    @Column(name = "apply_date")
    public Date getApplyDate() {
        return applyDate;
    }
    public void setApplyDate(Date applyDate) {
        this.applyDate = applyDate;
    }
    @Column(name = "patient_apply_date")
    public Date getPatientApplyDate() {
        return patientApplyDate;
    }
    public void setPatientApplyDate(Date patientApplyDate) {
        this.patientApplyDate = patientApplyDate;
    }
    @Column(name = "patient_apply_unsgin_date")
    public Date getPatientApplyUnsignDate() {
        return patientApplyUnsignDate;
    }
    public void setPatientApplyUnsignDate(Date patientApplyUnsignDate) {
        this.patientApplyUnsignDate = patientApplyUnsignDate;
    }
    @Column(name = "family_code")
    public String getFamilyCode() {
        return familyCode;
    }
    public void setFamilyCode(String familyCode) {
        this.familyCode = familyCode;
    }
    @Column(name = "expenses")
    public Double getExpenses() {
        return expenses;
    }
    public void setExpenses(Double expenses) {
        this.expenses = expenses;
    }
    @Column(name = "sign_doctor_code")
    public String getSignDoctorCode() {
        return signDoctorCode;
    }
    public void setSignDoctorCode(String signDoctorCode) {
        this.signDoctorCode = signDoctorCode;
    }
    @Column(name = "sign_doctor_name")
    public String getSignDoctorName() {
        return signDoctorName;
    }
    public void setSignDoctorName(String signDoctorName) {
        this.signDoctorName = signDoctorName;
    }
    @Column(name = "sign_doctor_level")
    public String getSignDoctorLevel() {
        return signDoctorLevel;
    }
    public void setSignDoctorLevel(String signDoctorLevel) {
        this.signDoctorLevel = signDoctorLevel;
    }
    @Column(name = "apply_unsign_date")
    public Date getApplyUnsignDate() {
        return applyUnsignDate;
    }
    public void setApplyUnsignDate(Date applyUnsignDate) {
        this.applyUnsignDate = applyUnsignDate;
    }
    @Column(name = "expenses_type")
    public String getExpensesType() {
        return expensesType;
    }
    public void setExpensesType(String expensesType) {
        this.expensesType = expensesType;
    }
    @Column(name = "sign_year")
    public String getSignYear() {
        return signYear;
    }
    public void setSignYear(String signYear) {
        this.signYear = signYear;
    }
    @Column(name = "medical_insurance_num")
    public String getMedicalInsuranceNum() {
        return medicalInsuranceNum;
    }
    public void setMedicalInsuranceNum(String medicalInsuranceNum) {
        this.medicalInsuranceNum = medicalInsuranceNum;
    }
    @Column(name = "agent_doctor_code")
    public String getAgentDoctorCode() {
        return agentDoctorCode;
    }
    public void setAgentDoctorCode(String agentDoctorCode) {
        this.agentDoctorCode = agentDoctorCode;
    }
    @Column(name = "agent_doctor_name")
    public String getAgentDoctorName() {
        return agentDoctorName;
    }
    public void setAgentDoctorName(String agentDoctorName) {
        this.agentDoctorName = agentDoctorName;
    }
    @Column(name = "agent_doctor_level")
    public String getAgentDoctorLevel() {
        return agentDoctorLevel;
    }
    public void setAgentDoctorLevel(String agentDoctorLevel) {
        this.agentDoctorLevel = agentDoctorLevel;
    }
    @Column(name = "expenses_status")
    public String getExpensesStatus() {
        return expensesStatus;
    }
    public void setExpensesStatus(String expensesStatus) {
        this.expensesStatus = expensesStatus;
    }
    @Column(name = "sign_source")
    public String getSignSource() {
        return signSource;
    }
    public void setSignSource(String signSource) {
        this.signSource = signSource;
    }
    @Column(name = "admin_team_code")
    public Long getAdminTeamId() {
        return adminTeamId;
    }
    public void setAdminTeamId(Long adminTeamId) {
        this.adminTeamId = adminTeamId;
    }
    @Override
    public String toString() {
        return "SignFamily{" +
                "code='" + code + '\'' +
                ", lwCode='" + lwCode + '\'' +
                ", type=" + type +
                ", patient='" + patient + '\'' +
                ", openid='" + openid + '\'' +
                ", name='" + name + '\'' +
                ", idcard='" + idcard + '\'' +
                ", ssc='" + ssc + '\'' +
                ", mobile='" + mobile + '\'' +
                ", emerMobile='" + emerMobile + '\'' +
                ", hospital='" + hospital + '\'' +
                ", hospitalName='" + hospitalName + '\'' +
                ", doctor='" + doctor + '\'' +
                ", doctorName='" + doctorName + '\'' +
                ", doctorHealth='" + doctorHealth + '\'' +
                ", doctorHealthName='" + doctorHealthName + '\'' +
                ", begin=" + begin +
                ", end=" + end +
                ", status=" + status +
                ", images='" + images + '\'' +
                ", reason='" + reason + '\'' +
                ", czrq=" + czrq +
                ", teamCode='" + teamCode + '\'' +
                ", applyDate=" + applyDate +
                ", signType='" + signType + '\'' +
                ", familyCode='" + familyCode + '\'' +
                '}';
    }
    public Date getExpensesTime() {
        return expensesTime;
    }
    public void setExpensesTime(Date expensesTime) {
        this.expensesTime = expensesTime;
    }
    @Column(name="is_valid")
    public Integer getIsValid() {
        return isValid;
    }
    public void setIsValid(Integer isValid) {
        this.isValid = isValid;
    }
}

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/SignEndJob.java

@ -35,6 +35,7 @@ public class SignEndJob implements Job {
            int sucessT = jdbcTemplate.update(sqlT, start, end);
            int sucessTm = jdbcTemplate.update(sqlTm, start, end);
            int sucess = jdbcTemplate.update(sql, start, end);
            renewToSign();
            System.out.println("sign end job end");
        } catch (Exception e) {
            e.printStackTrace();
@ -42,4 +43,7 @@ public class SignEndJob implements Job {
        }
    }
    public void renewToSign(){
    }
}

+ 4 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java

@ -13,19 +13,19 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
    Consult findByCode(String code);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, long id, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    Page<Object> findByPatient(String patient, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
    @Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")

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

@ -12,7 +12,4 @@ public interface PatientHealthTimeDao extends PagingAndSortingRepository<Patient
    @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);
}

+ 12 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/HealthEduArticlePatientDao.java

@ -11,12 +11,18 @@ import java.util.List;
public interface HealthEduArticlePatientDao extends PagingAndSortingRepository<HealthEduArticlePatient, Long>, JpaSpecificationExecutor<HealthEduArticlePatient> {
	// 更新为已读
	@Modifying
	@Query("update HealthEduArticlePatient a set a.read = 0 where a.patient = ?1 and a.article = ?2 ")
	int updateRead(String patient, String article);
	HealthEduArticlePatient findByArticle(String article);
    // 更新为已读
    @Modifying
    @Query("update HealthEduArticlePatient a set a.read = 0 where a.patient = ?1 and a.article = ?2 ")
    int updateRead(String patient, String article);
	List<HealthEduArticlePatient> findByArticleAndPatient(String article,String patient);
    HealthEduArticlePatient findByArticle(String article);
    List<HealthEduArticlePatient> findByArticleAndPatient(String article, String patient);
    // 当前用户的所有未读文章设置为已读
    @Modifying
    @Query("update HealthEduArticlePatient a set a.read = 0 where a.read = 1 and a.patient = ?1 ")
    int readAllArticle(String patient);
}

+ 33 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java

@ -0,0 +1,33 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamilyRenew, Long>, JpaSpecificationExecutor<SignFamilyRenew> {
    @Query("select a from SignFamilyRenew a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
    SignFamilyRenew findByIdcard(String idcard);
    /**
     * 获取所有有效的签约信息(不包含-1 -2)
     *
     * @param patient
     * @return
     */
    @Query(value = "select a from SignFamilyRenew a where a.patient = ?1 and a.status <> -1 and a.status <> -2")
    List<SignFamilyRenew> findAllActiveSignByPatient(String patient);
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient);
    List<SignFamilyRenew> findByDoctorHealthAndPatient(String doctorHealth,String patient);
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -33,6 +33,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
@ -111,6 +112,7 @@ public class DoctorInfoService extends BaseService {
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    /**
     * 获取医生的签约病人
     *

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java

@ -7,6 +7,7 @@ import java.util.List;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.SendPatientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -55,6 +56,9 @@ public class ConsultService extends BaseService {
	@Autowired
	private SignFamilyDao signFamilyDao;
	@Autowired
	private PatientService patientService;
	/**
	 * 添加一条咨询记录
	 * @param patient 患者信息
@ -72,6 +76,7 @@ public class ConsultService extends BaseService {
		consult.setSymptoms(symptoms);
		consult.setImages(images);
		consult.setType(type);
		consult.setSignCode(patientService.getSignCodeByPatient(patient));
		return consultDao.save(consult);
	}

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

@ -505,7 +505,7 @@ public class PatientDeviceService extends BaseService {
     */
    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) {
                             String beforeSleepStart, String beforeSleepEnd) throws  Exception{
        PatientHealthTime patientHealthTime = new PatientHealthTime();
        patientHealthTime.setUser(user);
        patientHealthTime.setDeviceSN(deviceSN);

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -17,6 +17,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.task.PushMsgTask;
@ -77,6 +78,9 @@ public class FollowUpService extends BaseService {
    @Autowired
    SystemDictService dictService;
    @Autowired
    private PatientService patientService;
    /**
     * 转译随访信息
     */
@ -309,6 +313,9 @@ public class FollowUpService extends BaseService {
                followup.setCreater(doctorCode);
                followup.setAdminTeamCode(signFamily.getAdminTeamId());
                followup.setSignType(2);
                //新增签约保存CODE
                followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
                followupPlan.add(followup);
            }
@ -399,6 +406,9 @@ public class FollowUpService extends BaseService {
        followup.setCreater(doctorCode);
        followup.setAdminTeamCode(signFamily.getAdminTeamId());
        followup.setSignType(2);
        //保存质询code
        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
        followupDao.save(followup);
        re = String.valueOf(followup.getId());
        return re;

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/HealthEduArticleService.java

@ -256,6 +256,16 @@ public class HealthEduArticleService extends BaseService {
        return healthEduArticlePatientDao.updateRead(patient, article);
    }
    /**
     * 对当前用户的所有未读文章设置为已读
     *
     * @param patient
     * @return
     */
    public int readAllArticle(String patient) {
        return healthEduArticlePatientDao.readAllArticle(patient);
    }
    /**
     * 发送文章列表
     *

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientHealthGuidanceDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
@ -46,6 +47,8 @@ public class PatientHealthGuidanceService extends BaseService {
	JdbcTemplate jdbcTemplate;
	@Autowired
	WeiXinOpenIdUtils weiXinOpenIdUtils;
	@Autowired
	private PatientService patientService;
	public JSONObject findById(Long id){
		PatientHealthGuidance guidance = patientHealthGuidanceDao.findOne(id);
@ -111,6 +114,8 @@ public class PatientHealthGuidanceService extends BaseService {
		guidance.setDel("1");
		guidance.setAdminTeamCode(signFamily.getAdminTeamId());
		guidance.setSignType(2);
		//保存签约CODE
		guidance.setSignCode(patientService.getSignCodeByPatient(patient.getCode()));
		guidance = patientHealthGuidanceDao.save(guidance);
		String openId = null;

+ 99 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -12,20 +12,14 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyCode;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.repository.statistics.WlyySignFamilyCodeDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
@ -122,6 +116,9 @@ public class FamilyContractService extends BaseService {
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
    public SignFamily findSignFamilyByCode(String code) {
        return signFamilyDao.findByCodeAndType(code, 2);
    }
@ -2876,4 +2873,98 @@ public class FamilyContractService extends BaseService {
        return result;
    }
    /**
     * 续签申请
     *
     * @param doctor  签约医生
     * @param patient 居民code
     * @return
     */
    public int signRenew(String doctor,String healthDoctor, String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
        SignFamilyRenew sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
        //判断身份证号是否已签约
        if (sc != null) {
            return -2;
        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
        if (d == null) {
            return -3;
        }
        if (hd == null) {
            return -3;
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        sf.setCode(getCode());
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        sf.setDoctor(doctor);
        sf.setDoctorName(d.getName());
        sf.setDoctorHealth(healthDoctor);
        sf.setDoctorHealthName(hd.getName());
        sf.setMobile(p.getMobile());
        sf.setName(p.getName());
        sf.setIdcard(p.getIdcard());
        sf.setOpenid(p.getOpenid());
        sf.setPatient(patient);
        sf.setHospital(d.getHospital());
        sf.setHospitalName(d.getHospitalName());
        sf.setSsc(p.getSsc());
        sf.setStatus(0);//0为初始状态
        sf.setType(2);// 设置为家庭签约
        sf.setSignType("1");//用户申请
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        sf.setIsValid(0);
        SignFamilyRenew temp = signFamilyRenewDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent(p.getName()+"申请与您续签家庭医生");
            message.setRead(1);//设置未读
            message.setReceiver(doctor);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(p.getName());
            message.setCode(getCode());
            message.setSenderPhoto(p.getPhoto());
            message.setTitle("家庭签约申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            message.setSignStatus("1");//新的签约
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(temp.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                PushMsgTask.getInstance().put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
            }
        }
        return 1;
    }
}

+ 299 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -6,12 +6,17 @@ 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.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
@ -53,6 +58,10 @@ public class SignWebService extends BaseService {
    private AdminTeamService adminTeamService;
    @Autowired
    private SystemDictService systemDictService;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -356,8 +365,58 @@ public class SignWebService extends BaseService {
    }
    public JSONArray getSigns(String patient){
        List<SignFamily> signFamilys =  signFamilyDao.findAllActiveSignByPatient(patient);
        JSONArray jsonArray = new JSONArray();
        //加入续签表数据
//        List<SignFamilyRenew> renews = jdbcTemplate.queryForList(
//                "SELECT * FROM wlyy_sign_family_renew t " +
//                        "WHERE t.patient = '"+patient+"' AND t.status <> -1 and t.status <> -2",SignFamilyRenew.class);
        List<SignFamilyRenew> renews = signFamilyRenewDao.findAllActiveSignByPatient(patient);
        for(SignFamilyRenew renew: renews){
            AdminTeam adminTeam = null;
            Doctor doctor = null;
            if(renew.getAdminTeamId()!=null){
                adminTeam = adminTeamService.getTeam(renew.getAdminTeamId());
                doctor = doctorService.findDoctorByCode(adminTeam.getLeaderCode());
            }
            if(adminTeam==null)adminTeam = new AdminTeam();
            if(doctor==null)doctor = new Doctor();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("hospitalName",renew.getHospitalName());
            jsonObject.put("hospital",renew.getHospital());
            jsonObject.put("code",renew.getCode());
            jsonObject.put("teamCode",renew.getTeamCode());
            jsonObject.put("begin",renew.getBegin());
            jsonObject.put("end",renew.getEnd());
            jsonObject.put("status",renew.getStatus());
            jsonObject.put("leader",adminTeam.getLeaderCode());
            jsonObject.put("leaderName",doctor.getName());
            jsonObject.put("doctor",renew.getDoctor());
            jsonObject.put("doctorHealth",renew.getDoctorHealth());
            jsonObject.put("doctorName",renew.getDoctorName());
            jsonObject.put("doctorHealthName",renew.getDoctorHealthName());
            jsonObject.put("expensesStatus",StringUtils.isNotBlank(renew.getExpensesStatus())?renew.getExpensesStatus():"1");
            jsonObject.put("applyDate",renew.getApplyDate());
            jsonObject.put("createTime",renew.getCzrq());
            jsonObject.put("type",renew.getType());
            jsonObject.put("typeName",renew.getType()==1?"三师签约":"家庭签约");
            String statusName = "";
            switch (jsonObject.getInt("status")){
                case -4 : statusName = "已到期";break;
                case -3 : statusName ="已解约";break;
                case 0 : statusName ="待审核";break;
                case 1 : if(jsonObject.getInt("expensesStatus")==1){statusName ="已签约";}else{statusName ="待缴费";} break;
                case 2 : statusName ="患者申请取消签约";break;
                case 3 : statusName ="医生申请取消签约";break;
            }
            jsonObject.put("statusName",statusName);
            jsonArray.put(jsonObject);
        }
        //查询签约表数据
        List<SignFamily> signFamilys =  signFamilyDao.findAllActiveSignByPatient(patient);
        for(SignFamily signFamily: signFamilys){
            AdminTeam adminTeam = null;
            Doctor doctor = null;
@ -656,4 +715,243 @@ public class SignWebService extends BaseService {
        return resultObject;
    }
    /**
     * 根据医生代码及签约状态编码 获取该医生续签患者的信息列表
     *
     * @param doctor
     * @param status
     * @param page
     * @param pageSize
     * @return
     */
    public List<Map<String, Object>> getSignRenewWebByDoctor(String doctor, int status, int page, int pageSize) {
        // 查询语句
        String sql = "select " +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.idcard " +
                "    ,b.name " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                (status == 1 ? "    ,a.patient_apply_date as applyDate " : "    ,a.expenses_time as applyDate ") +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc limit " + page * pageSize + "," + pageSize;
        // 未缴费查询语句
        String sqlExpenses = "select " +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.idcard " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                "    ,a.apply_date as applyDate " +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and (a.expenses_status = '0' or a.len < 1) order by a.begin desc limit " + page * pageSize + "," + pageSize;
        //1:待签约 2, 待缴费 3 已签约
        Page<Object> list = null;
        List<Map<String, Object>> patients = null;
        switch (status) {
            case 1:// 待处理
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 0});
                break;
            case 2:// 待缴费
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 1});
                break;
            case 3:// 已签约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 1});
                break;
        }
        return patients;
    }
    /**
     * 批量提醒用户
     * @param access_token
     * @param doctor
     * @return
     * @throws Exception
     */
    public int sendRenewToPatients(String access_token,String doctor) throws Exception{
        String sql = "SELECT p.name,p.openid,t.doctor_name doctorName,p.code,p.mobile FROM wlyy_sign_family t ,wlyy_patient p " +
                "WHERE t.patient = p.code AND t.doctor = ? AND t.status >=0 AND t.expenses_status ='1' AND " +
                "NOT EXISTS" +
                "(SELECT 1 FROM wlyy_sign_family_renew a WHERE a.patient =t.patient)  ";
        List<Map<String,Object>> signFamilies = jdbcTemplate.queryForList(sql,new Object[]{doctor});
        if(signFamilies!=null&&signFamilies.size()>0){
            for(Map<String,Object> signFamily : signFamilies){
                String openid = (String)signFamily.get("openid");
                String name = (String)signFamily.get("name");
                String doctorName =(String)signFamily.get("doctorName");
                JSONObject json = new JSONObject();
                json.put("keyword1", "续签家庭医生");
                json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("remark","提醒医生 :"+doctorName+"\n"
                        +"我们将继续为您提供优质的健康服务。");
                if(StringUtils.isNotBlank(openid)){
                    json.put("first",name+",您好!\n" +
                            "您的家庭医生签约将于7月31日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
                    PushMsgTask.getInstance().putWxMsg(access_token, 16, openid, name, json);
                    return 1;
                }else{
                    //如果自己没有绑定,则发给家人
                    String code = (String)signFamily.get("code");
                    JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(code);
                    Patient member = (Patient)j.get("member");
                    Patient p = patientService.findByCode(code);
                    if(StringUtils.isNotBlank(member.getOpenid())){
                        json.put("first",weiXinOpenIdUtils.getTitleMes(p,(int)j.get("relation"),member.getName())+"\n"+
                                name+",您好!\n" +
                                "您的家庭医生签约将于7月31日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 16, member.getOpenid(), member.getName(), json);
                        return 1;
                    }else{
                        //发送短信
                        String mobile = (String)signFamily.get("mobile");
                        if(StringUtils.isNotBlank(mobile)){
                            SMSService.sendMsg(mobile,name+"您好!您的家庭医生将于7月31日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                            return 2;
                        }
                    }
                }
            }
        }
        return 0;
    }
    /**
     * 同意或拒绝签约签约
     * @param access_token
     * @param dotorCode
     * @param state 1成功 0拒绝
     * @return
     * @throws Exception
     */
    public int agreeRenew(String access_token,String dotorCode,String patientCode,String state) throws Exception{
        List<SignFamilyRenew> renews =  signFamilyRenewDao.findByDoctorAndPatient(dotorCode,patientCode);
        if(renews==null||renews.size()==0){
            renews =  signFamilyRenewDao.findByDoctorHealthAndPatient(dotorCode,patientCode);
        }
        if(renews!=null&&renews.size()>0){
            for(SignFamilyRenew renew : renews){
                if(StringUtils.isNotBlank(state)){
                    if ("0".equals(state)){
                        renew.setStatus(-2);
                    }else if("1".equals(state)){
                        renew.setStatus(1);
                    }
                }
                renew.setStatus(1);
                signFamilyRenewDao.save(renew);
                //发送微信模板消息
                JSONObject data = new JSONObject();
                data.put("doctorName",renew.getDoctorName());
                data.put("date",DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                data.put("content","家庭医生续签");
                Patient patient = patientService.findByCode(renew.getPatient());
                if(patient!=null && StringUtils.isNotBlank(patient.getOpenid())){
                    if ("0".equals(state)){
                        data.put("first",renew.getName()+",您好!\n"+
                                "您的家庭医生续签申请已被拒绝");
                        data.put("remark","您可在到期后选择其他医生进行签约。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 2, patient.getOpenid(), patient.getName(), data);
                    }else if("1".equals(state)){
                        data.put("first",renew.getName()+",您好!\n"+
                                "您的家庭医生续签申请已通过");
                        data.put("remark","待自动扣费成功后,家庭医生将续签成功。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 1, patient.getOpenid(), patient.getName(), data);
                    }
                }else{
                    //如果自己没有绑定,则发给家人
                    JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patient.getCode());
                    Patient member = (Patient)j.get("member");
                    if(StringUtils.isNotBlank(member.getOpenid())){
                        if ("0".equals(state)){
                            data.put("first",weiXinOpenIdUtils.getTitleMes(patient,(int)j.get("relation"),member.getName())+"\n"+
                                    patient.getName()+",您好!\n" +
                                    "您的家庭医生续签申请已被拒绝");
                            data.put("remark","您可在到期后选择其他医生进行签约。");
                            PushMsgTask.getInstance().putWxMsg(access_token, 2, member.getOpenid(), member.getName(), data);
                        }else if("1".equals(state)){
                            data.put("first",weiXinOpenIdUtils.getTitleMes(patient,(int)j.get("relation"),member.getName())+"\n"+
                                    patient.getName()+",您好!\n" +
                                    "您的家庭医生续签申请已通过");
                            data.put("remark","待自动扣费成功后,家庭医生将续签成功。");
                            PushMsgTask.getInstance().putWxMsg(access_token, 1, member.getOpenid(), member.getName(), data);
                        }
                    }
                }
            }
        }
        return 1;
    }
    /**
     * 获取年度列表
     * @return
     */
    public JSONObject getRenewYearCount(String doctorCode){
        StringBuffer sql = new StringBuffer("SELECT t.sign_year,COUNT(1) count " +
                "FROM  wlyy_sign_family t WHERE t.doctor ='"+doctorCode+"' AND t.end <=NOW() AND t.status=-4 AND sign_year IS NOT NULL GROUP BY t.sign_year DESC");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result",rs);
        return json;
    }
    /**
     * 获取用户信息
     * @return
     */
    public JSONObject getOverDuePatients(String year,String doctorCode,Integer page,Integer pageSize){
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "p.code,p.idcard,p.name,p.mobile,p.openid,p.phone,p.photo," +
                "p.ssc,t.sign_type,p.sex,t.emer_mobile,t.expenses_time,t.expenses_status " +
                "FROM wlyy_sign_family t ,wlyy_patient p " +
                "WHERE t.patient = p.code AND t.doctor ='"+doctorCode+"' AND t.sign_year ='"+year+"' LIMIT "+page*pageSize+","+pageSize+";");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result",rs);
        return json;
    }
}

+ 70 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
@ -30,6 +31,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.utils.Clock;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -295,7 +297,74 @@ public class PatientService extends TokenService {
        return null;
    }
    /**
     * 判断是否续签
     * @param patient
     * @return
     */
    public JSONObject checkCanRenew(String patient){
        return  null;
        // 是否可以续签逻辑
        //A:wlyy_sign_family
        //B: wlyy_sign_family_renew
        //签约状态(-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约,3医生申请取消签约
        //扣费状态 【0未扣费 1已扣费 2已退费】
        JSONObject rs = new JSONObject();
        //判断是否签约
        List<SignFamily> signs =  jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status ='1' AND  t.patient ='"+patient+"'  AND NOW() >= t.begin AND NOW() <= t.end",SignFamily.class);
        if(signs!=null){
            //当前年度已经签约
            rs.put("issign","1");
        }else{
            //当前年度未签约
            rs.put("issign","0");
        }
        //A表有已签约,但还没有扣费的记录的,不允许续签
        List<SignFamily>  signFamilys1 = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status <>'1' AND t.patient ='"+patient+"'",SignFamily.class);
        if(signFamilys1!=null){
            rs.put("isrenew","0");
            return rs;
        }
        //A表有已签约,且已扣费,当前日期超过了7月1日,且当前日期在合约的有效期范围内,不允许续签
        Calendar calendar =Calendar.getInstance();
        String year = calendar.get(Calendar.YEAR)+"";
        List<SignFamily>  signFamilys2 = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status ='1' AND  t.patient ='"+patient+"' AND CURDATE()>'"+year+"-07-01' NOW() >= t.begin and NOW() <= t.end",SignFamily.class);
        if(signFamilys2!=null){
            rs.put("isrenew","0");
            return rs;
        }
        //B表:已签约且未生效,不允许续签
        List<SignFamilyRenew> signFamilyRenews = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family_renew t WHERE t.status>=0 AND  t.is_valid = 0 AND t.patient ='"+patient+"'",SignFamilyRenew.class);
        if(signFamilyRenews!=null){
            rs.put("isrenew","0");
            return rs;
        }
        //都未有记录则允许续签
        rs.put("isrenew","1");
        return rs;
    }
    /**
     * 根据居民ID查询签约CODE
     * @param patient
     * @return
     */
    public String getSignCodeByPatient(String patient){
        if(StringUtils.isBlank(patient)){
            return "";
        }
        try{
            List<SignFamily> signFamilies = jdbcTemplate.queryForList("SELECT * FROM wlyy_sign_family WHERE t.patient = '"+patient+"' AND t.status >=0 AND t.expenses_status ='1' ",SignFamily.class);
            if(signFamilies!=null && signFamilies.size()>0){
                return signFamilies.get(0).getCode();
            }
        }catch (Exception e){
            return "";
        }
        return "";
    }
}

+ 9 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -524,6 +524,15 @@ public class PushMsgTask {
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
            }else if(type == 16){
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties().getProperty("template_doctor_survey"));
                WechatTemplateData  keyword1= new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                WechatTemplateData  keyword2= new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }
            temp.setData(m);

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -282,7 +282,7 @@ public class ManagerUtilController extends BaseController {
    public String startEvaluateScoreJob() {
        try {
            if (!quartzHelper.isExistJob("evaluate_score_job")) {
                quartzHelper.addJob(SignEndJob.class, "59 59 23 * * ?", "evaluate_score_job", new HashMap<String, Object>());
                quartzHelper.addJob(EvaluateScoreJob.class, "59 59 23 * * ?", "evaluate_score_job", new HashMap<String, Object>());
                return write(200, "启动成功");
            } else {
                return write(200, "任务已存在");

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -611,6 +611,7 @@ public class DoctorController extends BaseController {
                //获取医生角色和区域权限
                List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(temp.getCode());
                json.put("userRole", roleMap);
                json.put("evaluateScore", temp.getEvaluateScore());
//                是否团队长
                json.put("isLeader", leader == 0 ? "0" : "1");
                return write(200, "医生信息查询成功!", "data", json);

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

@ -414,6 +414,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
                    heap.setBatchNo(batchNo);
                    //创建时间
                    heap.setCzrq(createTime);
                    heap.setSignCode(patientService.getSignCodeByPatient(p));
                    list.add(heap);
                    consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle()+ "\",\"type\":0,\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patientTemp.getName());
                    if(StringUtils.isNotBlank(attachedContent)){

+ 165 - 14
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -1,28 +1,28 @@
package com.yihu.wlyy.web.doctor.sign;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 医生端:签约管理控制类
@ -33,7 +33,7 @@ import com.yihu.wlyy.web.BaseController;
@RestController
@RequestMapping(value = "/doctor/sign", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-签约管理")
public class DoctorSignController extends BaseController {
public class DoctorSignController extends WeixinBaseController {
    //	@Autowired
//	private SignContractService signContractService;
@ -344,4 +344,155 @@ public class DoctorSignController extends BaseController {
            return error(-1,"查询失败");
        }
    }
    /**
     * 获取续签约患者信息
     *
     * @param status     签约状态 1:待签约 2 待缴费 3 已签约
     * @return
     */
    @RequestMapping("/sign_info_renew")
    @ApiOperation(value = "医生获取获取列表")
    public String getSignRenewInfoByDoctor(
            @RequestParam(required = true)int status,
            @RequestParam(required = true)int page,
            @RequestParam(required = true)int pageSize) {
        try {
            page = page > 0 ? page -1 : 0;
            List<Map<String, Object>> listSign = signWebService.getSignRenewWebByDoctor(getUID(), status, page, pageSize);
            //List<Map<String, Object>> listSign = signWebService.getSignRenewWebByDoctor("64de930c-5b15-11e6-8344-fa163e8aee56", status, page, pageSize);
            JSONObject data = new JSONObject();
            List<JSONObject> jsonArray = new ArrayList<>();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            if (listSign != null) {
                for (Map<String, Object> temp : listSign) {
                    if (temp == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("code", temp.get("code"));
                    json.put("doctorCode", temp.get("doctor"));
                    json.put("patientCode", temp.get("patient"));
                    json.put("patientName", temp.get("name"));
                    json.put("age", IdCardUtil.getAgeForIdcard(String.valueOf(temp.get("idcard"))));
                    json.put("provinceName", temp.get("provinceName"));
                    json.put("cityName", temp.get("cityName"));
                    json.put("townName", temp.get("townName"));
                    json.put("address", temp.get("address"));
                    json.put("photo", temp.get("photo"));
                    json.put("status", temp.get("status"));
                    json.put("openid", temp.get("openid"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
                            statusName = "待签约";
                            break;
                        case 1:
                            statusName = "已签约";
                            break;
                        case 2:
                            statusName = "待解约";
                            break;
                        case -3:
                        case -4:
                            statusName = "已解约";
                            break;
                    }
                    json.put("statusName", statusName);
                    json.put("id", temp.get("id"));
                    json.put("applyDate", DateUtil.dateToStrLong((Date) temp.get("applyDate")));
                    json.put("releaseSpeak", temp.get("reason"));
                    json.put("streetName", temp.get("streetName"));
                    json.put("sex", temp.get("sex"));
                    jsonArray.add(json);
                }
            }
            data.put("list", jsonArray);
            return write(200, "查询成功!", "data", data);
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(-1, "系统错误,请联系管理员!");
        }
    }
    /**
     * 批量提醒居民续签
     * @return
     */
    @RequestMapping("/sendRenewToPatients")
    @ApiOperation(value = "提醒用户签约")
    public String sendRenewToPatients(){
        try{
            int rs = signWebService.sendRenewToPatients(getAccessToken(),getUID());
            //int rs = signWebService.sendRenewToPatients(getAccessToken(),"64de930c-5b15-11e6-8344-fa163e8aee56");
            if(rs == 0){
                return error(-1, "微信和短信,提醒失败");
            }else{
                return write(200, "提醒成功!", "data", rs);
            }
        }catch (Exception e){
            return error(-1, "提醒失败");
        }
    }
    /**
     * 同意或拒绝
     * @param state
     * @return
     */
    @RequestMapping("/agreeRenew")
    @ApiOperation(value = "医生处理签约")
    public String agreeRenew(@RequestParam(required = true)String state,
                             @RequestParam(required = true)String patient){
        try{
            int rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state);
            //int rs =signWebService.agreeRenew(getAccessToken(),"64de930c-5b15-11e6-8344-fa163e8aee56",patient,state);
            if(rs == 0){
                return error(-1, "操作失败");
            }else{
                return write(200, "操作成功!", "data", rs);
            }
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
    /**
     * 获取用户详情列表
     * @param year
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping("/getOverDuePatients")
    @ApiOperation(value = "获取用户详情列表")
    public String getOverDuePatients(@RequestParam(required = true)String year,
                                     @RequestParam(required = true)Integer page,
                                     @RequestParam(required = true)Integer pageSize){
        try{
            JSONObject rs =signWebService.getOverDuePatients(year,getUID(),page,pageSize);
            //JSONObject rs =signWebService.getOverDuePatients(year,"64de930c-5b15-11e6-8344-fa163e8aee56",page,pageSize);
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
    /**
     *
     * 获取去医生下年度分组列表
     * @return
     */
    @RequestMapping("/getRenewYearCount")
    @ApiOperation(value = "获取年度分组")
    public String getRenewYearCount(){
        try{
            //JSONObject rs =signWebService.getRenewYearCount(getUID());
            JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -106,6 +106,9 @@ public class ConsultController extends WeixinBaseController {
                    json.put("doctorCode", result[7]);
                    json.put("teamCode", result[8]);
                    json.put("evaluate", result[9]);
                    array.put(json);
                }
            }

+ 10 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -66,10 +66,16 @@ public class PatientDeviceController extends BaseController {
                               @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;
        try {
            String user = getUID();
            patientDeviceService.setBloodTime(user,deviceSN,fastingStart,fastingEnd,afterBreakfastStart,afterBreakfastEnd,beforeLunchStart,beforeLunchEnd,
                    afterLunchStart,afterLunchEnd,beforeDinnerStart,beforeDinnerEnd,afterDinnerStart,afterDinnerEnd,beforeSleepStart,beforeSleepEnd);
            return write(200,"设置成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e,-1,"设置失败!");
        }
    }
    /**

+ 165 - 138
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java

@ -33,148 +33,175 @@ import java.util.Map;
/**
 * 患者端:健康教育控制类
 * @author George
 *
 * @author George
 */
@Controller
@RequestMapping(value = "/patient/health/edu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-健康教育")
public class HealthEduArticleController extends BaseController {
	@Autowired
	private HealthEduArticlePatientService healthEduArticlePatientService;
	@Autowired
	private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
	@Autowired
	private HealthEduArticleService healthEduArticleService;
	@Autowired
	private DoctorService doctorService;
	/**
	 * 查询文章列表
	 * @param pagesize 分页大小
	 * @return 列表
	 */
	@RequestMapping(value = "list")
	@ResponseBody
	public String list(@RequestParam("id")long id, @RequestParam("pagesize") int pagesize,@RequestParam(required = true,value="wheaType")int wheaType) {
		try {
			List<HealthEduArticlePatient> list = healthEduArticlePatientService.findByPatient(getUID(),wheaType, id, pagesize);
			JSONArray jsonArray = new JSONArray();
			Map<String,Doctor> docMap = new HashMap<>();
			if (list != null) {
				for (HealthEduArticlePatient article : list) {
					JSONObject json = new JSONObject();
					json.put("id", article.getId());
					// 文章标识
					json.put("article", article.getArticle());
					// 医生姓名
					json.put("doctorName", article.getDoctorName());
					// 文章标题
					json.put("title", article.getTitle());
					// 文章查看URL
					json.put("url", article.getUrl());
					// 文章简介
					//json.put("content", parsrHtml(article.getContent()));
					json.put("content", article.getContent());
					// 是否已读:0已读,1未读
					json.put("read", article.getRead());
					// 添加日期
					json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
					//附加内容
					json.put("attached_content", article.getAttachedContent());
					if(docMap.get(article.getDoctor())==null){
						Doctor doctor = doctorService.findDoctorByCode(article.getDoctor());
						docMap.put(article.getDoctor(),doctor);
						json.put("photo",doctor.getPhoto());
					}else{
						json.put("photo",docMap.get(article.getDoctor()).getPhoto());
					}
					jsonArray.put(json);
				}
			}
			return write(200, "查询成功", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询文章列表
	 * @param article 数据文章唯一标示article
	 * @return 列表
	 */
	@RequestMapping(value = "article")
	@ResponseBody
	public String article(@RequestParam(value = "article",required = true) String article) {
		try {
			//获取单条文章记录
			List<HealthEduArticlePatient> healthEduArticlePatients = healthEduArticlePatientService.findByArticleAndPatient(article,getUID());
			if(healthEduArticlePatients==null||healthEduArticlePatients.size()==0){
				return error(-2,"对不起,该消息不是您的消息,您无法查看哦~");
			}
			int isRead  = healthEduArticleOpHistoryService.countByUserStatus(getUID(),HealthEduArticleOpHistory.READ_STATUS);
			//插入文章读取状态第一次阅读记录浏览数量//暂时更新每次都算一次浏览量
			HealthEduArticlePatient healthEduArticlePatient = healthEduArticlePatients.get(0);
			healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS,healthEduArticlePatient.getArticle(),healthEduArticlePatient.getTitle(),getUID());
			if(isRead==0){
				//将文章更新为已读
				healthEduArticlePatientService.updateRead(getUID(), healthEduArticlePatient.getArticle());
			}
			HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(healthEduArticlePatient.getArticle());
			JSONObject json = new JSONObject();
			json.put("id", healthEduArticle.getId());
			// 文章标识
			json.put("article", healthEduArticlePatient.getArticle());
			// 医生姓名
			json.put("doctorName", healthEduArticlePatient.getDoctorName());
			// 文章标题
			json.put("title", healthEduArticle.getTitle());
			// 文章内容
			json.put("content", healthEduArticle.getContent());
			json.put("url", healthEduArticle.getUrl());
			// 添加日期
			json.put("czrq", DateUtil.dateToStrLong(healthEduArticlePatient.getCzrq()));
			int readAmount = healthEduArticleOpHistoryService.countReadAmount(healthEduArticlePatient.getArticle());
			json.put("readAmount",readAmount);
			return write(200, "查询成功", "data", json);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 更新文章为已读
	 * @param article 文章标识
	 * @return
	 */
	@RequestMapping(value = "read")
	@ResponseBody
	public String read(@RequestParam("article") String article) {
		try {
			healthEduArticlePatientService.updateRead(getUID(), article);
			return success("操作成功!");
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "操作失败!");
		}
	}
	private String parsrHtml(String html) throws ParserException {
		Parser parser = null;
		html = ("<span>"+html+"<span>");
		try{
			parser = new Parser(html);
		}catch (ParserException e){
			return html;//纯文本内容会转换失败,直接返回文本内容
		}
		TextExtractingVisitor visitor = new TextExtractingVisitor();
		parser.visitAllNodesWith(visitor);
		return StringUtils.isNotBlank(visitor.getExtractedText())?visitor.getExtractedText():"内容为图集,请点击查看";
	}
}
    @Autowired
    private HealthEduArticlePatientService healthEduArticlePatientService;
    @Autowired
    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
    @Autowired
    private HealthEduArticleService healthEduArticleService;
    @Autowired
    private DoctorService doctorService;
    /**
     * 查询文章列表
     *
     * @param pagesize 分页大小
     * @return 列表
     */
    @RequestMapping(value = "list")
    @ResponseBody
    public String list(@RequestParam("id") long id, @RequestParam("pagesize") int pagesize, @RequestParam(required = true, value = "wheaType") int wheaType) {
        try {
            List<HealthEduArticlePatient> list = healthEduArticlePatientService.findByPatient(getUID(), wheaType, id, pagesize);
            JSONArray jsonArray = new JSONArray();
            Map<String, Doctor> docMap = new HashMap<>();
            if (list != null) {
                for (HealthEduArticlePatient article : list) {
                    JSONObject json = new JSONObject();
                    json.put("id", article.getId());
                    // 文章标识
                    json.put("article", article.getArticle());
                    // 医生姓名
                    json.put("doctorName", article.getDoctorName());
                    // 文章标题
                    json.put("title", article.getTitle());
                    // 文章查看URL
                    json.put("url", article.getUrl());
                    // 文章简介
                    //json.put("content", parsrHtml(article.getContent()));
                    json.put("content", article.getContent());
                    // 是否已读:0已读,1未读
                    json.put("read", article.getRead());
                    // 添加日期
                    json.put("czrq", DateUtil.dateToStrLong(article.getCzrq()));
                    //附加内容
                    json.put("attached_content", article.getAttachedContent());
                    if (docMap.get(article.getDoctor()) == null) {
                        Doctor doctor = doctorService.findDoctorByCode(article.getDoctor());
                        docMap.put(article.getDoctor(), doctor);
                        json.put("photo", doctor.getPhoto());
                    } else {
                        json.put("photo", docMap.get(article.getDoctor()).getPhoto());
                    }
                    jsonArray.put(json);
                }
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 查询文章列表
     *
     * @param article 数据文章唯一标示article
     * @return 列表
     */
    @RequestMapping(value = "article")
    @ResponseBody
    public String article(@RequestParam(value = "article", required = true) String article) {
        try {
            //获取单条文章记录
            List<HealthEduArticlePatient> healthEduArticlePatients = healthEduArticlePatientService.findByArticleAndPatient(article, getUID());
            if (healthEduArticlePatients == null || healthEduArticlePatients.size() == 0) {
                return error(-2, "对不起,该消息不是您的消息,您无法查看哦~");
            }
            int isRead = healthEduArticleOpHistoryService.countByUserStatus(getUID(), HealthEduArticleOpHistory.READ_STATUS);
            //插入文章读取状态第一次阅读记录浏览数量//暂时更新每次都算一次浏览量
            HealthEduArticlePatient healthEduArticlePatient = healthEduArticlePatients.get(0);
            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS, healthEduArticlePatient.getArticle(), healthEduArticlePatient.getTitle(), getUID());
            if (isRead == 0) {
                //将文章更新为已读
                healthEduArticlePatientService.updateRead(getUID(), healthEduArticlePatient.getArticle());
            }
            HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(healthEduArticlePatient.getArticle());
            JSONObject json = new JSONObject();
            json.put("id", healthEduArticle.getId());
            // 文章标识
            json.put("article", healthEduArticlePatient.getArticle());
            // 医生姓名
            json.put("doctorName", healthEduArticlePatient.getDoctorName());
            // 文章标题
            json.put("title", healthEduArticle.getTitle());
            // 文章内容
            json.put("content", healthEduArticle.getContent());
            json.put("url", healthEduArticle.getUrl());
            // 添加日期
            json.put("czrq", DateUtil.dateToStrLong(healthEduArticlePatient.getCzrq()));
            int readAmount = healthEduArticleOpHistoryService.countReadAmount(healthEduArticlePatient.getArticle());
            json.put("readAmount", readAmount);
            return write(200, "查询成功", "data", json);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    /**
     * 更新文章为已读
     *
     * @param article 文章标识
     * @return
     */
    @RequestMapping(value = "read")
    @ResponseBody
    public String read(@RequestParam("article") String article) {
        try {
            healthEduArticlePatientService.updateRead(getUID(), article);
            return success("操作成功!");
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "操作失败!");
        }
    }
    private String parsrHtml(String html) throws ParserException {
        Parser parser = null;
        html = ("<span>" + html + "<span>");
        try {
            parser = new Parser(html);
        } catch (ParserException e) {
            return html;//纯文本内容会转换失败,直接返回文本内容
        }
        TextExtractingVisitor visitor = new TextExtractingVisitor();
        parser.visitAllNodesWith(visitor);
        return StringUtils.isNotBlank(visitor.getExtractedText()) ? visitor.getExtractedText() : "内容为图集,请点击查看";
    }
    /**
     * 对当前用户的所有未读文章设置为已读
     *
     * @return
     */
    @RequestMapping(value = "/readAllArticle",method = RequestMethod.GET)
    @ResponseBody
    public String readAllArticle() {
        try {
            String patient = getUID();
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
            int row = healthEduArticleService.readAllArticle(patient);
            System.out.println(row);
            return write(200,"更改状态成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e,-1,"更改状态失败!");
        }
    }
    }

+ 44 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -463,6 +463,38 @@ public class FamilyContractController extends BaseController {
        }
    }
    /**
     * 续签申请
     *
     * @param doctor     医生code
     * @return
     */
    @RequestMapping(value = "signRenew")
    @ResponseBody
    public String signRenew(@RequestParam(required = true) String doctor,
                            @RequestParam(required = true) String healthDoctor,
                            @RequestParam(required = true) String patient) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
            }
            int result = familyContractService.signRenew(doctor,healthDoctor,patient);
            if (result == -1) {
                return error(-1, "用户信息查询失败");
            } else if (result == -2) {
                return error(-1, "用户已存在签约");
            } else if (result == -3) {
                return error(-1, "医生信息查询失败");
            } else {
                return write(200, "签约申请成功");
            }
        } catch (Exception e) {
            return error(-1, "签约申请失败");
        }
    }
    /**
     * 取消签约申请
     *
@ -613,9 +645,19 @@ public class FamilyContractController extends BaseController {
        }
    }
    /**
     * 验证是否允许签约
     * @param patient
     * @return
     */
    @RequestMapping(value = "/checkCanRenew", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String checkCanRenew(String patient){
        return  null;
    public String checkCanRenew(@RequestParam(required = true) String patient){
        try {
            JSONObject result = patientService.checkCanRenew(patient);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
}

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

@ -274,6 +274,7 @@ public class PatientSignController extends BaseController {
	public String getSigns() {
		try {
			JSONArray jsonArray  = signWebService.getSigns(getUID());
			//JSONArray jsonArray  = signWebService.getSigns("915cc456-5b1d-11e6-8344-fa163e8aee56");
			return write(200, "查询成功!", "data", jsonArray);
		} catch (Exception ex) {
			ex.printStackTrace();