Browse Source

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

chenweida 8 years ago
parent
commit
236d44a450
38 changed files with 1803 additions and 646 deletions
  1. 338 320
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java
  2. 62 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/reply/DoctorQuickReply.java
  3. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/followup/Followup.java
  4. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorPatientDao.java
  5. 33 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorQuickReplyDao.java
  6. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  7. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  8. 5 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/security/TokenDao.java
  9. 56 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientEventService.java
  10. 4 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientRecordService.java
  11. 2 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java
  12. 30 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  13. 171 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  14. 111 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java
  15. 28 11
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  16. 145 26
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java
  17. 77 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  18. 227 101
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  19. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoYihuService.java
  20. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/IGuahaoService.java
  21. 78 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java
  22. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  23. 8 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/fastdfs/FastDFSUtil.java
  24. 3 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  25. 5 14
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java
  26. 34 18
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  27. 2 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  28. 113 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java
  29. 70 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  30. 13 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  31. 68 11
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java
  32. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  33. 72 79
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java
  34. 15 5
      patient-co-wlyy/src/main/resources/application.properties
  35. 1 0
      patient-co-wlyy/src/main/resources/applicationContext.xml
  36. 2 2
      patient-co-wlyy/src/main/resources/config/fdfs_client.conf
  37. 1 1
      patient-co-wlyy/src/main/resources/system.properties
  38. 10 0
      patient-co-wlyy/src/main/resources/weixin_menu.txt

+ 338 - 320
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java

@ -14,313 +14,318 @@ import com.fasterxml.jackson.annotation.JsonFormat;
/**
 * 医生信息
 *
 * @author George
 */
@Entity
@Table(name = "wlyy_doctor")
public class Doctor extends IdEntity {
	private static final long serialVersionUID = -6585552029939285364L;
    
	private String code;        // 业务主键
	
	private String name;
	private Integer sex;        // 性别(1男,2女)
	private Date birthday;
	private String photo;
	private String mobile;
	private String password;
	private String salt;        // 密码标识
	private Integer status;     // 状态(1正常,0禁用)
	
	private String province;
	private String city;
	private String town;
	private String provinceName;
	private String cityName;
    private static final long serialVersionUID = -6585552029939285364L;
    private String code;        // 业务主键
    private String name;
    private Integer sex;        // 性别(1男,2女)
    private Date birthday;
    private String photo;
    private String mobile;
    private String password;
    private String salt;        // 密码标识
    private Integer status;     // 状态(1正常,0禁用)
    private String province;
    private String city;
    private String town;
    private String provinceName;
    private String cityName;
    private String townName;
	
	private String hospital;        // 医院代码
	private String hospitalName;
	private String dept;            // 科室代码
	private String deptName;
	private String job;             // 职称代码
	private String jobName;         // 职称名
	
	private String expertise;       // 医生专长
	private String introduce;       // 医生介绍
	
	private Integer level;          // 类型:1专科医生,2全科医生,3健康管理师
	private Integer iscertified;   // 资格是否认证通过,1是,0否
    private String hospital;        // 医院代码
    private String hospitalName;
    private String dept;            // 科室代码
    private String deptName;
    private String job;             // 职称代码
    private String jobName;         // 职称名
    private String expertise;       // 医生专长
    private String introduce;       // 医生介绍
    private Integer level;          // 类型:1专科医生,2全科医生,3健康管理师
    private Integer iscertified;   // 资格是否认证通过,1是,0否
    private String qrcode;          // 二维码
	
	private Date czrq;              // 更新时间
	private Integer del;            // 状态(1正常,0删除)
	private String idcard;          //身份证号
	private Integer isFamous;       //是否是名医 1是  0或者空不是
	private String isPasswordPrompt;// 是否提示密码信息 1是 0或者空是否
	private String isHelp;//是否求助  1已经求助 0未求助
	public Doctor() {}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public Doctor(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getSalt() {
		return salt;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getTown() {
		return town;
	}
	public void setTown(String town) {
		this.town = town;
	}
	
	@Column(name = "province_name")
	public String getProvinceName() {
		return provinceName;
	}
	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	@Column(name = "city_name")
	public String getCityName() {
		return cityName;
	}
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	@Column(name = "town_name")
	public String getTownName() {
		return townName;
	}
	public void setTownName(String townName) {
		this.townName = townName;
	}
	public String getHospitalName() {
		return hospitalName;
	}
	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}
	@Column(name = "dept_name")
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	@Column(name = "job_name")
	public String getJobName() {
		return jobName;
	}
	public void setJobName(String jobName) {
		this.jobName = jobName;
	}
	public String getHospital() {
		return hospital;
	}
	public void setHospital(String hospital) {
		this.hospital = hospital;
	}
	public String getDept() {
		return dept;
	}
	public void setDept(String dept) {
		this.dept = dept;
	}
	public String getJob() {
		return job;
	}
	public void setJob(String job) {
		this.job = job;
	}
	public String getExpertise() {
		return expertise;
	}
	public void setExpertise(String expertise) {
		this.expertise = expertise;
	}
	public String getIntroduce() {
		return introduce;
	}
	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}
	public Integer getLevel() {
		return level;
	}
	public void setLevel(Integer level) {
		this.level = level;
	}
    private Date czrq;              // 更新时间
    private Integer del;            // 状态(1正常,0删除)
    private String idcard;          //身份证号
    private Integer isFamous;       //是否是名医 1是  0或者空不是
    private String isPasswordPrompt;// 是否提示密码信息 1是 0或者空是否
    private String isHelp;//是否求助  1已经求助 0未求助
    public Doctor() {
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public Doctor(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getSalt() {
        return salt;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getProvince() {
        return province;
    }
    public void setProvince(String province) {
        this.province = province;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    @Column(name = "province_name")
    public String getProvinceName() {
        return provinceName;
    }
    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }
    @Column(name = "city_name")
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    @Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "job_name")
    public String getJobName() {
        return jobName;
    }
    public void setJobName(String jobName) {
        this.jobName = jobName;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    public String getJob() {
        return job;
    }
    public void setJob(String job) {
        this.job = job;
    }
    public String getExpertise() {
        return expertise;
    }
    public void setExpertise(String expertise) {
        this.expertise = expertise;
    }
    public String getIntroduce() {
        return introduce;
    }
    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }
    public Integer getLevel() {
        return level;
    }
    public void setLevel(Integer level) {
        this.level = level;
    }
    @Column(name = "iscertified")
    public Integer getIscertified() {
		return iscertified;
	}
	public void setIscertified(Integer isCertified) {
		this.iscertified = isCertified;
	}
	public String getQrcode() {
		return qrcode;
	}
	public void setQrcode(String qrcode) {
		this.qrcode = qrcode;
	}
	// 设定JSON序列化时的日期格式
	@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;
	}
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	@Column(name = "del")
	public Integer getDel() {
		return del;
	}
	public void setDel(Integer del) {
		this.del = del;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	@Column(name = "is_famous")
	public Integer getIsFamous() {
		return isFamous;
	}
	public void setIsFamous(Integer isFamous) {
		this.isFamous = isFamous;
	}
        return iscertified;
    }
    public void setIscertified(Integer isCertified) {
        this.iscertified = isCertified;
    }
    public String getQrcode() {
        return qrcode;
    }
    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }
    // 设定JSON序列化时的日期格式
    @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;
    }
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "is_famous")
    public Integer getIsFamous() {
        return isFamous;
    }
    public void setIsFamous(Integer isFamous) {
        this.isFamous = isFamous;
    }
    /**
     * 是否为专科医生。
@ -328,8 +333,12 @@ public class Doctor extends IdEntity {
     * @return
     */
    @Transient
	public boolean isProfessionalDoctor(){
	    return level == 1;
    public boolean isProfessionalDoctor() {
        if (level != null && level == 1) {
            return true;
        } else {
            return false;
        }
    }
    /**
@ -338,8 +347,12 @@ public class Doctor extends IdEntity {
     * @return
     */
    @Transient
	public boolean isGeneralDoctor(){
	    return level == 2;
    public boolean isGeneralDoctor() {
        if (level != null && level == 2) {
            return true;
        } else {
            return false;
        }
    }
    /**
@ -348,24 +361,29 @@ public class Doctor extends IdEntity {
     * @return
     */
    @Transient
    public boolean isHealthDoctor(){
        return level == 3;
    }
	@Transient
	public String getIsHelp() {
		return isHelp;
	}
	public void setIsHelp(String isHelp) {
		this.isHelp = isHelp;
	}
	@Column(name = "is_password_prompt")
	public String getIsPasswordPrompt() {
		return isPasswordPrompt;
	}
	public void setIsPasswordPrompt(String isPasswordPrompt) {
		this.isPasswordPrompt = isPasswordPrompt;
	}
    public boolean isHealthDoctor() {
        if (level != null && level == 3) {
            return true;
        } else {
            return false;
        }
    }
    @Transient
    public String getIsHelp() {
        return isHelp;
    }
    public void setIsHelp(String isHelp) {
        this.isHelp = isHelp;
    }
    @Column(name = "is_password_prompt")
    public String getIsPasswordPrompt() {
        return isPasswordPrompt;
    }
    public void setIsPasswordPrompt(String isPasswordPrompt) {
        this.isPasswordPrompt = isPasswordPrompt;
    }
}

+ 62 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/reply/DoctorQuickReply.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.entity.doctor.reply;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by lyr-pc on 2016/12/28.
 */
@Entity
@Table(name = "wlyy_doctor_quick_reply")
public class DoctorQuickReply extends IdEntity {
    // 医生
    private String doctor;
    // 回复内容
    private String content;
    // 排序
    private Integer sort;
    // 更新时间
    private Date updateTime;
    // 状态 1:有效  0:无效
    private Integer status;
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

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

@ -21,6 +21,8 @@ public class Followup extends IdEntity {
	private String followupNo;
	//随访时间
	private Date followupDate;
	//随访计划时间
	private Date followupPlanDate;
	//计划下次随访时间
	private Date followupNextDate;
	//随访方式【字典FOLLOWUP_WAY_DICT】
@ -54,6 +56,14 @@ public class Followup extends IdEntity {
	//创建者
	private String creater;
	public Date getFollowupPlanDate() {
		return followupPlanDate;
	}
	public void setFollowupPlanDate(Date followupPlanDate) {
		this.followupPlanDate = followupPlanDate;
	}
	public String getFollowupNo() {
		return followupNo;
	}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorPatientDao.java

@ -30,7 +30,7 @@ public interface DoctorPatientDao extends PagingAndSortingRepository<DoctorPatie
	List<Doctor> findDoctors(String patient, int teamType);
	//查询团队下所有的医生信息
	@Query("select a from Doctor a, DoctorTeamMember b where b.team = ?1 and a.code = b.memberCode and b.type <> 5")
	@Query("select a from Doctor a, DoctorTeamMember b where b.team = ?1 and a.code = b.memberCode and b.type <> 5 and b.del='1'")
	List<Doctor> findTeamDoctors(String team);
	// 更新家庭医生与患者关系为无效

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

@ -0,0 +1,33 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.reply.DoctorQuickReply;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr-pc on 2016/12/28.
 */
public interface DoctorQuickReplyDao extends PagingAndSortingRepository<DoctorQuickReply, Long> {
    @Query("select max(q.sort) from DoctorQuickReply q where q.doctor = ?1 and q.status = 1")
    Integer findMaxSort(String doctor);
    @Query("update DoctorQuickReply q set q.sort = q.sort - 1 where q.doctor = ?1 and q.sort > ?2 and q.status = 1")
    @Modifying
    int updateSort(String doctor,Integer sort);
    @Query("update DoctorQuickReply q set q.sort = q.sort - 1 where q.doctor = ?1 and q.sort > ?2 and q.sort <= ?3 and q.status = 1")
    @Modifying
    int updateSortLt(String doctor,Integer sort1,Integer sort2);
    @Query("update DoctorQuickReply q set q.sort = q.sort + 1 where q.doctor = ?1 and q.sort < ?2 and q.sort >= ?3 and q.status = 1")
    @Modifying
    int updateSortGt(String doctor,Integer sort1,Integer sort2);
    @Query("select q from DoctorQuickReply q where q.doctor = ?1 and q.status = 1")
    List<DoctorQuickReply> findDoctorReplies(String doctor, Sort sort);
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -23,4 +23,7 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.creater = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByCreater(String creater, Date begin, Date end, Pageable pageRequest) throws Exception;
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code = ?1 and a.patient_code = ?2 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String doctorCode,String patientCode) throws Exception;
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -329,7 +329,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	 * @param status
	 * @return
	 */
	@Query("select count(f) from SignFamily f where f.adminTeamId = ?1 and status >= ?2 ")
	@Query("select count(f) from SignFamily f where f.adminTeamId = ?1 and f.status >= ?2 ")
	int findByAdminTeamIdAndStatus(long teamCode,int status);
}

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/security/TokenDao.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.repository.security;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -35,4 +37,7 @@ public interface TokenDao extends PagingAndSortingRepository<Token, Long> {
	@Query("delete Token a where a.user = ?1 and a.platform = 3 and a.del = '1'")
	int deleteWxTokenByPatient(String patient);
	@Query("select a from Token a where a.imei = ?1 and a.platform = 3")
	Page<Token> findByOpenid(String openid, Pageable pageable);
}

+ 56 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientEventService.java

@ -59,9 +59,8 @@ public class PatientEventService {
     * 删除就诊事件
     */
    @Transactional
    public void deleteEvent(String id) throws Exception
    public void deleteEvent(Long eventId) throws Exception
    {
        Long eventId =Long.valueOf(id);
        PatientEvent event = patientEventDao.findOne(eventId);
        if(event!=null)
        {
@ -105,6 +104,8 @@ public class PatientEventService {
        event.setDeptCode(json.optString("deptCode"));
        event.setDeptName(json.optString("deptName"));
        event.setDianosis(json.optString("dianosis"));
        event.setDoctorCode(json.optString("doctorCode"));
        event.setDoctorName(json.optString("doctorName"));
        //保存就诊记录
        patientEventDao.save(event);
@ -146,16 +147,62 @@ public class PatientEventService {
    }
    /**
     * 删除就诊事件详情
     * 删除就诊事件图片
     */
    @Transactional
    public void deleteEventDetail(String id) throws Exception
    public void deleteEventImg(Long id) throws Exception
    {
        PatientEvent event = patientEventDao.findOne(Long.valueOf(id));
        patientEventDao.delete(event);
        List<PatientEventImg> list = patientEventImgDao.findByEventId(event.getId());
        patientEventImgDao.delete(list);
        PatientEventImg eventImg = patientEventImgDao.findOne(id);
        if(eventImg!=null)
        {
            patientEventImgDao.delete(eventImg);
        }
        else{
            throw new Exception("not exit image!id:"+id);
        }
    }
    /**
     * 新增就诊事件图片
     */
    public void addEventImg(Long eventId,String imgType,String imgLabel,String imgUrl) throws Exception
    {
        PatientEvent event = patientEventDao.findOne(eventId);
        if(event!=null) {
            PatientEventImg img = new PatientEventImg();
            img.setCreateTime(new Date());
            img.setEventId(eventId);
            // 图片类型(病历/处方/病理报告/检查报告/检验报告/其他)
            img.setImgType(imgType);
            // 图片标签
            img.setImgLabel(imgLabel);
            // 图片路径
            img.setImgUrl(imgUrl);
            patientEventImgDao.save(img);
        }
        else{
            throw new Exception("not exit event!id:"+eventId);
        }
    }
    /**
     * 修改就诊事件图片
     */
    public void editEventImg(Long id,String imgType,String imgLabel) throws Exception
    {
        PatientEventImg img = patientEventImgDao.findOne(id);
        if(img!=null)
        {
            // 图片类型(病历/处方/病理报告/检查报告/检验报告/其他)
            img.setImgType(imgType);
            // 图片标签
            img.setImgLabel(imgLabel);
            patientEventImgDao.save(img);
        }
        else{
            throw new Exception("not exit image!id:"+id);
        }
    }
}

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientRecordService.java

@ -237,6 +237,10 @@ public class PatientRecordService {
                    type = "检验";
                } else if ("0231".equals(item.optString("CATALOG_CODE"))) {
                    type = "检查";
                } else if ("0121".equals(item.optString("CATALOG_CODE"))) {
                    type = "检验";
                } else if ("0131".equals(item.optString("CATALOG_CODE"))) {
                    type = "检查";
                }
                map.put("type", type);
                map.put("catalogCode", item.optString("CATALOG_CODE")); //【基卫】档案类型

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java

@ -382,7 +382,8 @@ public class FamilyService {
                .replace("{doctorCode}", doctor.getCode())//医生code;
                .replace("{invilogcode}", code)//邀请记录code
                .replace("{currentPatient}", currentPatient.getCode())//当前用户的code
                .replace("{currentZH}", currentPatient.getMobile());//当前用户的账号
                .replace("{currentZH}", currentPatient.getMobile())//当前用户的账号
                .replace("{currentName}", currentPatient.getName()); //当前用户名;
        //发送模板
        JSONObject end = new JSONObject();
        end.put("value", "【点击帮助您的家庭成员完成签约】");

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

@ -196,7 +196,9 @@ public class FollowUpService extends BaseService {
				Followup followup = new Followup();
				followup.setFollowupType(map.get("type"));
				followup.setFollowupDate(DateUtil.strToDate(map.get("date")));
				Date date =  DateUtil.strToDate(map.get("date"));
				followup.setFollowupDate(date);
				followup.setFollowupPlanDate(date);
				followup.setDoctorCode(doctor.getCode());
				followup.setDoctorName(doctor.getName());
				followup.setOrgCode(doctor.getHospital());
@ -224,7 +226,9 @@ public class FollowUpService extends BaseService {
		Followup followup = followupDao.findOne(Long.valueOf(id));
		if(followup!=null)
		{
			followup.setFollowupDate(DateUtil.strToDate(date));
			Date followupDate = DateUtil.strToDate(date);
			followup.setFollowupDate(followupDate);
			followup.setFollowupPlanDate(followupDate);
			followup.setFollowupType(followupType);
			followup.setCreater(doctorCode);
@ -276,7 +280,9 @@ public class FollowUpService extends BaseService {
		}
		Followup followup = new Followup();
		followup.setFollowupDate(DateUtil.strToDate(date));
		Date followDate = DateUtil.strToDate(date);
		followup.setFollowupDate(followDate);
		followup.setFollowupPlanDate(followDate);
		followup.setDoctorCode(doctorCode);
		followup.setDoctorName(doctor.getName());
		followup.setOrgCode(doctor.getHospital());
@ -393,6 +399,27 @@ public class FollowUpService extends BaseService {
		return re;
	}
	/**
	 * 获取上次随访项目数据
	 */
	public Map<String,String> getLastFollowupProjectData(String doctor,String patient,String followupProject) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		Followup lastFollowup = followupDao.findLastFollowup(doctor,patient);
		if(lastFollowup!=null)
		{
			List<FollowupContent> dataList =  followupContentDao.findByFollowupIdAndFollowupProject(lastFollowup.getId(),followupProject);
			for(FollowupContent item:dataList)
			{
				re.put(item.getFollowupKey(),item.getFollowupValue());
			}
		}
		return re;
	}
	/**
	 *保存面访项目数据
	 */

+ 171 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import org.hibernate.type.descriptor.sql.JdbcTypeFamilyInformation;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
@ -173,6 +174,18 @@ public class SignPatientLabelInfoService extends BaseService {
            }
        }
        String epTime = "";
        try {
            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (StringUtils.isEmpty(epTime)) {
            json.put("wechatFocusRemind", 0);
        } else {
            json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
        }
        return json;
    }
@ -192,7 +205,7 @@ public class SignPatientLabelInfoService extends BaseService {
            throw new Exception("doctor info can not find");
        }
        Map<String, JSONObject> result = new HashMap<>();
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        int start = page * pagesize;
        String sql = "";
@ -227,7 +240,7 @@ public class SignPatientLabelInfoService extends BaseService {
            } else {
                throw new Exception("label is not exist");
            }
            sql += " order by openid desc,convert(name using gbk) ";
            args = new Object[]{doctor, doctor, teamCode};
        } else {
            if (labelCode.equals("0")) {
@ -242,7 +255,7 @@ public class SignPatientLabelInfoService extends BaseService {
                        "    t2.patient is null " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?) " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                        "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
                args = new Object[]{labelType, doctor, doctor, teamCode};
            } else {
@ -258,7 +271,7 @@ public class SignPatientLabelInfoService extends BaseService {
                        "    AND t1.patient = t2.patient " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                        "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
                args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
            }
@ -302,6 +315,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            }
                        }
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    continue;
@ -361,6 +385,17 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                }
                // 患者标签
                //json.put("labels", labels == null ? "" : labels);
@ -434,6 +469,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            }
                        }
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    continue;
                }
@ -506,6 +552,17 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -665,6 +722,23 @@ public class SignPatientLabelInfoService extends BaseService {
        return count;
    }
    /**
     * 获取团队签约人数
     *
     * @param teamCode
     * @return
     * @throws Exception
     */
    public int getPatientFocusAmountByTeam(Long teamCode) throws Exception {
        String sql = "select count(distinct patient) count from wlyy_sign_family where admin_team_code = ? and status > 0 and length(trim(ifnull(openid,''))) > 1";
        List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, new Object[]{teamCode});
        if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
            return Integer.valueOf(String.valueOf(count.get(0).get("count")));
        } else {
            return 0;
        }
    }
    /**
     * 查询某个标签类型的所有标签居民数统计,或者所有类型
     *
@ -1152,7 +1226,7 @@ public class SignPatientLabelInfoService extends BaseService {
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter  + "%"};
                args = new Object[]{doctor, doctor, "%" + filter + "%"};
            }
        } else {
            sql = "select " +
@ -1220,6 +1294,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            }
                        }
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    continue;
@ -1302,6 +1387,17 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -1662,6 +1758,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            }
                        }
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    continue;
@ -1741,6 +1848,17 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -1819,6 +1937,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            }
                        }
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    continue;
@ -1884,6 +2013,17 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
@ -1906,7 +2046,7 @@ public class SignPatientLabelInfoService extends BaseService {
     */
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize) throws Exception {
        Map<String, JSONObject> result = new HashMap<>();
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        int start = page * pagesize;
        String sql = "";
@ -1941,7 +2081,7 @@ public class SignPatientLabelInfoService extends BaseService {
            } else {
                throw new Exception("label is not exist");
            }
            sql += " order by openid desc,convert(name using gbk) ";
            args = new Object[]{teamCode};
        } else {
            if (labelCode.equals("0")) {
@ -1955,7 +2095,7 @@ public class SignPatientLabelInfoService extends BaseService {
                        " WHERE " +
                        "    t2.patient is null " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                        "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
                args = new Object[]{teamCode, labelType, teamCode};
            } else {
@ -1970,7 +2110,7 @@ public class SignPatientLabelInfoService extends BaseService {
                        "    AND t2.status = 1 " +
                        "    AND t1.patient = t2.patient " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                        "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
                args = new Object[]{labelCode, labelType, teamCode};
            }
@ -2015,6 +2155,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            }
                        }
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    continue;
@ -2074,6 +2225,17 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                String epTime = "";
                try {
                    epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isEmpty(epTime)) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind",  new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                }
                // 患者标签
                //json.put("labels", labels == null ? "" : labels);

+ 111 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java

@ -0,0 +1,111 @@
package com.yihu.wlyy.service.app.reply;
import com.yihu.wlyy.entity.doctor.reply.DoctorQuickReply;
import com.yihu.wlyy.repository.doctor.DoctorQuickReplyDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.print.Doc;
import java.util.Date;
import java.util.List;
/**
 * Created by lyr-pc on 2016/12/28.
 */
@Service
@Transactional
public class DoctorQuickReplyService extends BaseService {
    @Autowired
    DoctorQuickReplyDao quickReplyDao;
    /**
     * 添加快捷回复
     *
     * @param doctor  医生
     * @param content 快捷回复内容
     * @return
     */
    public DoctorQuickReply addReply(String doctor, String content) {
        DoctorQuickReply reply = new DoctorQuickReply();
        Integer sort = quickReplyDao.findMaxSort(doctor);
        sort = sort == null ? 1 : sort + 1;
        reply.setDoctor(doctor);
        reply.setContent(content);
        reply.setStatus(1);
        reply.setSort(sort);
        reply.setUpdateTime(new Date());
        return quickReplyDao.save(reply);
    }
    /**
     * 删除快捷回复
     *
     * @param id
     * @return
     */
    public int delReply(String doctor, long id) {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        // 快捷回复不存在
        if (reply == null) {
            return -1;
        }
        if (reply.getStatus() == 0) {
            return -1;
        }
        reply.setStatus(0);
        quickReplyDao.save(reply);
        quickReplyDao.updateSort(doctor, reply.getSort());
        return 1;
    }
    /**
     * 获取医生快捷回复列表
     *
     * @param doctor
     * @return
     */
    public List<DoctorQuickReply> getDoctorReplyList(String doctor) {
        Sort sort = new Sort(Sort.Direction.DESC, "sort");
        List<DoctorQuickReply> replies = quickReplyDao.findDoctorReplies(doctor, sort);
        return replies;
    }
    /**
     * 排序回复
     *
     * @param id
     * @param sort
     * @return
     */
    public int sortReply(String doctor, long id, int sort) {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        // 快捷回复不存在
        if (reply == null) {
            return -1;
        }
        if (reply.getStatus() == 0) {
            return -1;
        }
        if (reply.getSort() < sort) {
            quickReplyDao.updateSortLt(doctor, reply.getSort(), sort);
        } else if (reply.getSort() > sort) {
            quickReplyDao.updateSortGt(doctor, reply.getSort(), sort);
        } else {
            return -2;
        }
        reply.setSort(sort);
        quickReplyDao.save(reply);
        return 1;
    }
}

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

@ -879,15 +879,15 @@ public class FamilyContractService extends BaseService {
        end.set(Calendar.MINUTE,0);
        end.set(Calendar.SECOND,0);
        end.set(Calendar.MILLISECOND,0);
        end.set(Calendar.MONTH, 6);
        end.set(Calendar.MONTH, 5);
        end.set(Calendar.DATE,30);
        if (month < 3 || month > 6) {
            if (month > 6) {
        if (month < 2 || month > 5) {
            if (month > 5) {
                end.add(Calendar.YEAR, 1);
            }
        } else {
            begin.set(Calendar.MONTH, 7);
            begin.set(Calendar.MONTH, 6);
            begin.set(Calendar.DATE,1);
            end.add(Calendar.YEAR, 1);
        }
@ -1067,15 +1067,15 @@ public class FamilyContractService extends BaseService {
            end.set(Calendar.MINUTE,0);
            end.set(Calendar.SECOND,0);
            end.set(Calendar.MILLISECOND,0);
            end.set(Calendar.MONTH, 6);
            end.set(Calendar.MONTH, 5);
            end.set(Calendar.DATE,30);
            if (month < 3 || month > 6) {
                if (month > 6) {
            if (month < 2 || month > 5) {
                if (month > 5) {
                    end.add(Calendar.YEAR, 1);
                }
            } else {
                begin.set(Calendar.MONTH, 7);
                begin.set(Calendar.MONTH, 6);
                begin.set(Calendar.DATE,1);
                end.add(Calendar.YEAR, 1);
            }
@ -1560,7 +1560,7 @@ public class FamilyContractService extends BaseService {
                if (signFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(signFamily.getPatientApplyDate()));//申请时间
                } else if (signFamily.getStatus() == 1) {
                    jo.put("qyDate", DateUtil.dateToStrShort(signFamily.getApplyDate()));//签约时间
                    jo.put("qyDate", DateUtil.dateToStrShort(signFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(signFamily.getEnd()));//结束时间
                } else if (signFamily.getStatus() == 2) {
                    jo.put("qyDate", DateUtil.dateToStrShort(signFamily.getPatientApplyUnsignDate()));//申请解约时间
@ -1591,7 +1591,7 @@ public class FamilyContractService extends BaseService {
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getApplyDate()));//签约时间
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.put(jo);
@ -1611,7 +1611,7 @@ public class FamilyContractService extends BaseService {
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getApplyDate()));//签约时间
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.put(jo);
@ -2020,6 +2020,23 @@ public class FamilyContractService extends BaseService {
        return signFamilyDao.findNoHealthSignFamilyNum(teamCode);
    }
    /**
     * 获取未分配健管师关注公众号人数
     *
     * @param teamCode
     * @return
     * @throws Exception
     */
    public int findNoHealthSignFamilyFocusNum(Long teamCode) throws Exception {
        String sql = "select count(distinct patient) count from wlyy_sign_family where admin_team_code = ? and doctor_health is null and status > 0 and length(trim(ifnull(openid,''))) > 1";
        List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, new Object[]{teamCode});
        if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
            return Integer.valueOf(String.valueOf(count.get(0).get("count")));
        } else {
            return 0;
        }
    }
    /**
     * 判断居民与医生是否存在签约关系
     *

+ 145 - 26
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java

@ -14,16 +14,19 @@ import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.collections.FastHashMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -34,7 +37,7 @@ import java.util.concurrent.TimeUnit;
 * Created by lyr on 2016/10/24.
 */
@Service
public class ExpensesRemindService extends BaseService {
public class PatientRemindService extends BaseService {
    @Autowired
    SignFamilyDao signFamilyDao;
@ -86,31 +89,37 @@ public class ExpensesRemindService extends BaseService {
     */
    public void RemindAll(Doctor doc, Hospital hos) {
        try {
            String sql = "select distinct a.patient from " +
                    " (select patient,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len " +
            boolean flag = true;
            int page = 0;
            int start = 0;
            String sql = "select p.* " +
                    "     from " +
                    "        wlyy_sign_family " +
                    "     where "
                    + (doc.getLevel() == 2 ? "doctor" : "doctor_health") + " = ? " +
                    "        and status > 0 " +
                    "        and type = 2 " +
                    "        order by begin desc ) a" +
                    " where a.expenses_status = '0' or a.len < 1";
                    "        wlyy_sign_family f join wlyy_patient p on f.patient = p.code " +
                    "     where " +
                    "        (f.doctor = ? or f.doctor_health = ?) " +
                    "        and f.status > 0 " +
                    "        and f.type = 2 " +
                    "        and (f.expenses_status = '0' or LENGTH(trim(ifnull(f.expenses_status,''))) < 1) " +
                    "     limit ?,3000";
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doc.getCode()});
            while (flag) {
                List<Patient> result = jdbcTemplate.query(sql,new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper<Patient>());
            if (result != null && result.size() > 0) {
                for (Map<String, Object> map : result) {
                    Patient p = patientDao.findByCode(String.valueOf(map.get("patient")));
                    if (p != null) {
                        String epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                        if(StringUtils.isNotEmpty(epTime) &&
                                new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime)) {
                            continue;
                if (result != null && result.size() > 0) {
                    for (Patient p : result) {
                        if (p != null) {
                            String epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            if (StringUtils.isNotEmpty(epTime) &&
                                    new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime)) {
                                continue;
                            }
                            remindPatientExpenses(p, doc, hos, true);
                        }
                        remindPatientExpenses(p, doc, hos, true);
                    }
                    page = page + 1;
                    start = page * 3000;
                } else {
                    flag = false;
                }
            }
        } catch (Exception e) {
@ -147,8 +156,8 @@ public class ExpensesRemindService extends BaseService {
        } catch (Exception e) {
            e.printStackTrace();
            JSONObject reObj = new JSONObject();
            reObj.put("status",-1);
            reObj.put("msg",e.getMessage());
            reObj.put("status", -1);
            reObj.put("msg", e.getMessage());
            return reObj;
        }
    }
@ -199,7 +208,7 @@ public class ExpensesRemindService extends BaseService {
                wFlag = true;
            }
            //发送IM
            SendP2PUtil.sendP2Pmsg(doc.getCode(),p.getCode(),"1",doc.getName() + "医生提醒您:为完成家庭医生签约," +
            SendP2PUtil.sendP2Pmsg(doc.getCode(), p.getCode(), "1", doc.getName() + "医生提醒您:为完成家庭医生签约," +
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
            if (ignore) {
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
@ -237,9 +246,119 @@ public class ExpensesRemindService extends BaseService {
        } catch (Exception e) {
            e.printStackTrace();
            JSONObject reObj = new JSONObject();
            reObj.put("status",-1);
            reObj.put("msg",e.getMessage());
            reObj.put("status", -1);
            reObj.put("msg", e.getMessage());
            return reObj;
        }
    }
    /**
     * 提醒患者关注微信
     *
     * @param patient 患者
     * @param doctor  医生
     * @return
     */
    public JSONObject remindPatientFocusWechat(String patient, String doctor) {
        try {
            Doctor doc = doctorDao.findByCode(doctor);
            if (doc == null) {
                throw new Exception("doctor info can not find");
            }
            Patient p = patientDao.findByCode(patient);
            if (p == null) {
                throw new Exception("patient info can not find");
            }
            Map<String, Object> map = new HashMap<>();
            map.put("code", p.getCode());
            map.put("name", p.getName());
            map.put("mobile", p.getMobile());
            return remindWechatFocus(map, doc);
        } catch (Exception e) {
            e.printStackTrace();
            JSONObject reObj = new JSONObject();
            reObj.put("status", -1);
            reObj.put("msg", e.getMessage());
            return reObj;
        }
    }
    /**
     * 提醒所有患者关注微信
     *
     * @param doctor
     */
    @Async
    public void remindPatientWechatFocusAll(String doctor) throws Exception {
        int page = 0;
        int start = 0;
        boolean flag = true;
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        String sql = "select p.code,p.name,p.mobile" +
                "     from " +
                "        wlyy_sign_family f join wlyy_patient p on f.patient = p.code" +
                "     where " +
                "        (f.doctor = ? or f.doctor_health = ?) " +
                "        and f.status > 0 " +
                "        and f.expenses_status = '1' " +
                "        and LENGTH(trim(ifnull(p.openid,''))) < 1 limit ?,3000";
        while (flag) {
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, start});
            if (result != null && result.size() > 0) {
                for (Map<String, Object> map : result) {
                    remindWechatFocus(map, doc);
                }
                page = page + 1;
                start = page * 3000;
            } else {
                flag = false;
            }
        }
    }
    /**
     * 微信关注提醒
     *
     * @param p
     * @param doctor
     * @return
     */
    public JSONObject remindWechatFocus(Map<String, Object> p, Doctor doctor) {
        JSONObject result = new JSONObject();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        if (p.get("mobile") == null || StringUtils.isEmpty(p.get("mobile").toString())) {
            result.put("status", -1);
            result.put("msg", "对不起,居民未绑定手机号,无法短信提醒");
            redisTemplate.opsForValue().set("wechat:focus:remind:" + p.get("code").toString(), df.format(new Date()));
            redisTemplate.expire("wechat:focus:remind:" + p.get("code").toString(), 1, TimeUnit.DAYS);
            return result;
        }
        String msg = "尊敬的" + p.get("name").toString() + "," + doctor.getName() + "医生提醒您:" +
                "为更好地为您提供健康服务,请您关注并登录\"厦门i健康\"微信公众号,与医生进行互动。";
        JSONObject smsResult = smsService.sendMsg(p.get("mobile").toString(), msg);
        if (smsResult != null && smsResult.getInt("result") == 0) {
            result.put("status", 1);
            result.put("msg", "提醒成功");
        } else {
            result.put("status", -1);
            result.put("msg", "对不起,短信提醒失败,失败原因:" + smsResult.getString("description"));
        }
        return result;
    }
}

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

@ -14,15 +14,18 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.task.SignSsGetTask;
import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.utils.Clock;
@ -47,6 +50,10 @@ public class PatientService extends TokenService {
    private DoctorDao doctorDao;
    @Autowired
    private DoctorPatientDao doctorPatientDao;
    @Autowired
    TokenDao tokenDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    private Clock clock = Clock.DEFAULT;
@ -96,18 +103,34 @@ public class PatientService extends TokenService {
     *
     * @param patient
     */
    public void updatePatient(Patient patient, String openid) {
        if (patientDao.countByOpenid(openid) >= 10) {
            Sort sort = new Sort(Sort.Direction.ASC, "czrq");
            PageRequest pageRequest = new PageRequest(0, 1, sort);
            Page<Patient> pPage = patientDao.findPatientByOpenid(openid, pageRequest);
            for (Patient p : pPage) {
    public void updatePatient(Patient patient, String openid) throws Exception {
        Sort sort = new Sort(Sort.Direction.ASC, "czrq");
        PageRequest pageRequest = new PageRequest(0, 100, sort);
        Page<Token> tokens = tokenDao.findByOpenid(openid, pageRequest);
        if (tokens != null && tokens.getContent().size() >= 10) {
            int i = 0;
            int last = tokens.getContent().size() - 10;
            for (Token token : tokens) {
                i++;
                Patient p = patientDao.findByCode(token.getUser());
                if (p == null || i <= last) {
                    tokenDao.delete(token);
                    SystemData.wxPatientTokens.remove(token.getUser());
                    continue;
                }
                p.setOpenid("");
                signFamilyDao.updateOpenidByPatient("", p.getCode());
                patientDao.save(p);
                tokenDao.delete(token);
                SystemData.wxPatientTokens.remove(p.getCode());
                break;
            }
        }
        patient.setOpenid(openid);
        patientDao.save(patient);
        Patient ps = patientDao.save(patient);
        System.out.print(new JSONObject(ps));
        if (StringUtils.isNotEmpty(patient.getOpenid())) {
            signFamilyDao.updateOpenidByPatient(patient.getOpenid(), patient.getCode());
        }
@ -128,7 +151,7 @@ public class PatientService extends TokenService {
     * @return
     * @throws Exception
     */
    public JSONObject register(Patient patient, String imei, int platform) throws Exception {
    public JSONObject register_bak(Patient patient, String imei, int platform) throws Exception {
        IdcardInfoExtractor ie = new IdcardInfoExtractor(patient.getIdcard());
        patient.setBirthday(ie.getBirthday());
        patient.setSex(ie.getGender());
@ -161,6 +184,52 @@ public class PatientService extends TokenService {
        return null;
    }
    /**
     * 患者注册
     *
     * @param idcard
     * @param ssc
     * @param name
     * @param mobile
     * @param password
     * @param salt
     * @param imei
     * @param platform
     * @return
     * @throws Exception
     */
    public JSONObject register(String idcard, String ssc, String name, String mobile
            , String password, String salt, String imei, int platform) throws Exception {
        IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard);
        String code = getCode();
        String sql = "insert wlyy_patient(code,idcard,name,ssc,mobile,password,salt,openid" +
                ",status,birthday,sex,czrq,disease,disease_condition,record_amount,points)" +
                " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        jdbcTemplate.update(sql, new Object[]{code, idcard, name, ssc, mobile, password, salt, imei, 1, ie.getBirthday()
                , ie.getGender(), clock.getCurrentDate(), 0, 0, 0, 0});
        Patient temp = patientDao.findByCode(code);
        if (temp != null) {
            // 更新openid
            updatePatient(temp, imei);
            // 生成登录tokey
            Token token = newToken(temp.getCode(), imei, platform);
            if (token != null) {
                // 生成登录信息成功
                JSONObject json = new JSONObject();
                json.put("id", temp.getId());
                json.put("uid", temp.getCode());
                json.put("token", token.getToken());
                json.put("name", temp.getName());
                json.put("photo", temp.getPhoto());
                //new Thread(new SignSsGetTask(patient.getIdcard())).start();
                return json;
            }
        }
        return null;
    }
    /**
     * 建立三师团队与患者的关系
     *

+ 227 - 101
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SOAPUtil;
import com.yihu.wlyy.util.SendP2PUtil;
@ -50,6 +51,136 @@ public class GuahaoXMService implements IGuahaoService {
    private ObjectMapper objectMapper = new ObjectMapper();
    /**
     * 解析挂号后
     */
    private String CreateOrderAfter(String response,String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String sectionType,String startTime,String endTime,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception
    {
        String code = "";
        if(response.startsWith("error")||response.startsWith("System-Error"))
        {
            throw new Exception(response);
        }
        else if (response.toLowerCase().startsWith("ok")) {      //预约成功
            // 预约成功,获取预约号
            code = response.replace("OK:", "").replace("ok:", "");
        }
        else if(response.split("\\|").length==3){
            code = response.split("\\|")[0];
        }
        else{
            throw new Exception(response);
        }
        // 查询医生职称和头像
        GuahaoDoctor doctor =  GetDoctorInfo(doctorId,hospitalId,hosDeptId);
        // 保存预约记录
        PatientReservation reservation = new PatientReservation();
        reservation.setCode(code);
        reservation.setCzrq(new Date());
        reservation.setType("1");
        reservation.setOrgCode(hospitalId);
        reservation.setOrgName(hospitalName);
        reservation.setDeptCode(hosDeptId);
        reservation.setDeptName(hosDeptName);
        reservation.setDoctorCode(doctorId);
        reservation.setDoctorName(doctorName);
        reservation.setDoctorJob(doctor.getTitle());
        reservation.setDoctorPhoto(doctor.getPhoto());
        reservation.setIdcard(cardNo);
        reservation.setName(patientName);
        reservation.setPatient(patient);
        reservation.setPhone(patientPhone);
        reservation.setSectionType(sectionType);
        reservation.setSsc(clinicCard);
        reservation.setStartTime(startTime);
        reservation.setEndTime(endTime);
        reservation.setStatus(1);
        if(StringUtils.isNotBlank(dname)){
            reservation.setDname(dname);//代理签约维护待签约人名称
        }
        if(StringUtils.isNotBlank(dcode)){
            reservation.setDoctor(dcode);//代理签约维护待签约人编码
            SendP2PUtil.sendP2Pmsg(dcode,patient,"1","我已成功为您预约:"+startTime+","+hospitalName+hosDeptName+doctorName+"医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='"+code+"'>点击查看详情</a>");
        }
        // 保存预约记录
        patientReservationDao.save(reservation);
        return code;
    }
    /**
     * 预约排班xml转列表
     */
    private List<Map<String,Object>> xmlToList(String xml) throws Exception{
        List<Map<String,Object>> re = new ArrayList<>();
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取医生排班表失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        if(root.element("doctor")!=null)     //包含doctor节点
        {
            root = root.element("doctor");
        }
        List<?> child = root.elements();
        for (Object o : child) {
            Element e = (Element) o;
            // 日期
            String date = e.attributeValue("date");
            // a或者p
            String time = e.attributeValue("time");
            // 限号
            String max = e.attributeValue("max");
            // 已使用的号
            String used = e.attributeValue("used");
            // 1正常、2满号、3已过期
            String status = e.attributeValue("status");
            Map<String,Object> map = new HashMap<>();
            map.put("date", date);
            map.put("time", time);
            map.put("max", max);
            map.put("used", used);
            map.put("status", status);
            // 排班信息
            List<?> sections = e.elements();
            List<Map<String,String>> arrangeList = new ArrayList<>();
            for (Object s : sections) {
                Element section = (Element) s;
                // 限号
                String s_max = section.attributeValue("max");
                // 已使用的号
                String s_used = section.attributeValue("used");
                // 一次专家坐诊时间段的开始时间
                String start_time = section.attributeValue("start_time");
                // 结束时间
                String end_time = section.attributeValue("end_time");
                Map<String,String> item = new HashMap<>();
                item.put("max", s_max);
                item.put("used", s_used);
                item.put("startTime", start_time);
                item.put("endTime", end_time);
                arrangeList.add(item);
            }
            map.put("sections", arrangeList);
            re.add(map);
        }
        return re;
    }
    /***********************************************************************************************************************************************/
    /**
     * 获取医院列表
     */
@ -95,6 +226,10 @@ public class GuahaoXMService implements IGuahaoService {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }
            else if (StringUtils.startsWith(xml, "Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }
            Document document = DocumentHelper.parseText(xml);
            Element root = document.getRootElement();
            List<?> child = root.elements();
@ -116,7 +251,6 @@ public class GuahaoXMService implements IGuahaoService {
        return  re;
    }
    /**
     * 获取科室接口
     */
@ -137,6 +271,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
@ -192,6 +330,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
@ -248,7 +390,6 @@ public class GuahaoXMService implements IGuahaoService {
     * status 0 停诊、1正常、2满号、3已过期
     */
    public List<Map<String,Object>> GetDoctorArrange(String hospitalId,String hosDeptId,String doctorId) throws Exception{
        List<Map<String,Object>> re = new ArrayList<>();
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
@ -278,59 +419,8 @@ public class GuahaoXMService implements IGuahaoService {
        params.put(param5);
        String xml = SOAPUtil.post(DOCTOR_ARRANGE, params);
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取医生排班表失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
        for (Object o : child) {
            Element e = (Element) o;
            // 日期
            String date = e.attributeValue("date");
            // a或者p
            String time = e.attributeValue("time");
            // 限号
            String max = e.attributeValue("max");
            // 已使用的号
            String used = e.attributeValue("used");
            // 1正常、2满号、3已过期
            String status = e.attributeValue("status");
            Map<String,Object> map = new HashMap<>();
            map.put("date", date);
            map.put("time", time);
            map.put("max", max);
            map.put("used", used);
            map.put("status", status);
            // 排班信息
            List<?> sections = e.elements();
            List<Map<String,String>> arrangeList = new ArrayList<>();
            for (Object s : sections) {
                Element section = (Element) s;
                // 限号
                String s_max = section.attributeValue("max");
                // 已使用的号
                String s_used = section.attributeValue("used");
                // 一次专家坐诊时间段的开始时间
                String start_time = section.attributeValue("start_time");
                // 结束时间
                String end_time = section.attributeValue("end_time");
                Map<String,String> item = new HashMap<>();
                item.put("max", s_max);
                item.put("used", s_used);
                item.put("startTime", start_time);
                item.put("endTime", end_time);
                arrangeList.add(item);
            }
            map.put("sections", arrangeList);
            re.add(map);
        }
        return  re;
        return  xmlToList(xml);
    }
    /**
@ -375,6 +465,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
@ -404,9 +498,8 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 创建挂号单
     * update by linz 新增代签约人的code和name用于转诊预约
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception{
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -455,62 +548,30 @@ public class GuahaoXMService implements IGuahaoService {
            param3.put("value", values[2]);
            params.put(param3);
            String xml = SOAPUtil.post(ORDER_CREATE, params);
            if (StringUtils.isEmpty(xml)) {
            String response = SOAPUtil.post(ORDER_CREATE, params);
            if (StringUtils.isEmpty(response)) {
                // 请求失败
                throw new Exception("请求失败!");
            } else if (StringUtils.startsWith(xml, "System-Error")) {
            } else if (StringUtils.startsWith(response, "System-Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
            }  else if (StringUtils.startsWith(xml, "Error")) {
                throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
            }  else if (StringUtils.startsWith(response, "Error")) {
                // 调用失败
                throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
                throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
            }
            //预约成功
            if (xml.toLowerCase().startsWith("ok")) {
                // 预约成功,获取预约号
                String code = xml.replace("OK:", "");
                // 查询医生职称和头像
                GuahaoDoctor doctor =  GetDoctorInfo(doctorId,hospitalId,hosDeptId);
                // 保存预约记录
                PatientReservation reservation = new PatientReservation();
                reservation.setCode(code);
                reservation.setCzrq(new Date());
                reservation.setType("1");
                reservation.setOrgCode(hospitalId);
                reservation.setOrgName(hospitalName);
                reservation.setDeptCode(hosDeptId);
                reservation.setDeptName(hosDeptName);
                reservation.setDoctorCode(doctorId);
                reservation.setDoctorName(doctorName);
                reservation.setDoctorJob(doctor.getTitle());
                reservation.setDoctorPhoto(doctor.getPhoto());
                reservation.setIdcard(cardNo);
                reservation.setName(patientName);
                reservation.setPatient(patient);
                reservation.setPhone(patientPhone);
                reservation.setSectionType(sectionType);
                reservation.setSsc(clinicCard);
                reservation.setStartTime(startTime);
                reservation.setEndTime(endTime);
                reservation.setStatus(1);
                if(StringUtils.isNotBlank(dname)){
                    reservation.setDname(dname);//代理签约维护待签约人名称
                }
                if(StringUtils.isNotBlank(dcode)){
                    reservation.setDoctor(dcode);//代理签约维护待签约人编码
                    SendP2PUtil.sendP2Pmsg(dcode,patient,"1","我已成功为您预约:"+startTime+","+hospitalName+hosDeptName+doctorName+"医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='"+code+"'>点击查看详情</a>");
                }
                // 保存预约记录
                patientReservationDao.save(reservation);
                re = code;
            }
            re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,null,null);
        }
        else{
            throw new Exception("该排班信息错误或者不存在!");
        }
        return re;
    }
    /**
     * 取消挂号单
     */
@ -548,6 +609,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        if (xml.toLowerCase().startsWith("ok")) {
            return true;
        } else {
@ -589,6 +654,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
@ -685,6 +754,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
@ -764,6 +837,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
@ -872,6 +949,10 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
@ -937,4 +1018,49 @@ public class GuahaoXMService implements IGuahaoService {
            patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
            return patientReservation;
    }
    @Autowired
    JwSmjkService jwSmjkService;
    /******************************** 基卫内网服务 ************************************************/
    public List<Map<String,Object>> GetDoctorArrangeTenDay(String hospitalId,String hosDeptId,String doctorId) throws Exception {
        String strStart = DateUtil.getStringDateShort(); //当前时间;
        String strEnd = DateUtil.getNextDay(strStart,11);         //10天预约
        String response = jwSmjkService.getRegDeptSpeDoctorSectionList(hospitalId,hosDeptId,strStart,strEnd,doctorId);
        return xmlToList(response);
    }
    /**
     * 转诊预约挂号
     */
    public String CreateOrderByDoctor(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception
    {
        String re = "";
        Patient p = patientService.findByCode(patient);
        if (p == null) {
            throw new Exception("患者信息不存在!");
        }
        Map<String,String> map = objectMapper.readValue(arrangeDate,Map.class);
        if(map.containsKey("sectionType") && map.containsKey("startTime")) {
            String sectionType = map.get("sectionType");
            String startTime = map.get("startTime");
            String endTime = map.get("endTime");
            String response = jwSmjkService.webRegisterByFamily(cardNo,patientName,clinicCard,sectionType,startTime,hospitalId,hosDeptId,hosDeptName,doctorId,doctorName);
            re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,dname,dcode);
        }
        else{
            throw new Exception("该排班信息错误或者不存在!");
        }
        return re;
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoYihuService.java

@ -227,7 +227,7 @@ public class GuahaoYihuService implements IGuahaoService {
    /**
     * 创建挂号单
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception{
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
        return  "";
    }

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/IGuahaoService.java

@ -38,7 +38,7 @@ public interface IGuahaoService{
	/**
	 * 创建挂号单
	 */
	public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode ) throws Exception;
	public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception;
	/**
	 * 获取医生信息

+ 78 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java

@ -93,6 +93,12 @@ public class JwSmjkService {
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            if(re.equals("[{}]"))
            {
                re = "";
            }
            return re;
        }
    }
@ -228,6 +234,11 @@ public class JwSmjkService {
                    throw new Exception("null response.");
                }
                if(re.equals("[{}]"))
                {
                    re = "";
                }
                return re;
            }
            catch (Exception ex)
@ -271,6 +282,10 @@ public class JwSmjkService {
                throw new Exception("null response.");
            }
            if(result.equals("[{}]"))
            {
                result = "";
            }
            return result;
        }
@ -279,7 +294,7 @@ public class JwSmjkService {
    /****************************************************************************************************************************/
    /**
     * 获取转诊预约医生号源信息
     * (内网)获取转诊预约医生号源信息
     */
    public String getRegDeptSpeDoctorSectionList(String OrgCode,String DeptCode,String strStart,String strEnd,String DocCode)  throws Exception
    {
@ -293,10 +308,71 @@ public class JwSmjkService {
        params.add(new BasicNameValuePair("strEnd", strEnd));
        params.add(new BasicNameValuePair("DocCode", DocCode));
        return HttpClientUtil.post(url, params, "UTF-8");
        String response =  HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data) && (data.startsWith("error")||data.startsWith("System-Error"))) {
                    throw new Exception(data);
                } else {
                    re = data;
                }
            } else {
                throw new Exception(jsonObject.getString("msg"));
            }
        } else {
            throw new Exception("null response.");
        }
        return re;
    }
    /**
     * (内网)预约挂号接口
     */
    public String webRegisterByFamily(String idcard,String patientName,String ssid,String sectionType,String startTime,String orgCode,String deptCode,String deptName,String doctorCode,String doctorName)  throws Exception
    {
        String re = "";
        String url = jwUrl + "/third/smjk/WebRegisterByFamily";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("patientName", patientName));
        params.add(new BasicNameValuePair("ssid", ssid));
        params.add(new BasicNameValuePair("sectionType", sectionType));
        params.add(new BasicNameValuePair("startTime", startTime));
        params.add(new BasicNameValuePair("orgCode", orgCode));
        params.add(new BasicNameValuePair("deptCode", deptCode));
        params.add(new BasicNameValuePair("deptName", deptName));
        params.add(new BasicNameValuePair("doctorCode", doctorCode));
        params.add(new BasicNameValuePair("doctorName", doctorName));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)) {
            JSONObject jsonObject = new JSONObject(response);
            int status = jsonObject.getInt("status");
            if (status == 200) {
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data) && (data.startsWith("error")||data.startsWith("System-Error"))) {
                    return "111111|aaaaaa|zzzz";
                    //throw new Exception(data);
                } else {
                    re = data;
                }
            } else {
                throw new Exception(jsonObject.getString("msg"));
            }
        } else {
            throw new Exception("null response.");
        }
        //返回挂号单
        return re;
    }

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

@ -333,7 +333,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("date"));
                m.put("keyword4", keyword4);
            } else if (type == 6) {
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid + "&id=" + json.getLong("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid+ "&orgCode=" + json.get("orgCode")  + "&id=" + json.getString("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                temp_id = SystemConf.getInstance().getSystemProperties().getProperty("template_appoint_success");
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();

+ 8 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/fastdfs/FastDFSUtil.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.util.fastdfs;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
@ -51,7 +52,7 @@ public class FastDFSUtil {
//        }
//    }
    final static int BUFFER_SIZE = 4096;
    /**
     * 以输入流的方式上传文件
@ -90,14 +91,13 @@ public class FastDFSUtil {
            ObjectMapper objectMapper = new ObjectMapper();
            ObjectNode message = objectMapper.createObjectNode();
            byte fileBuffer[] = new byte[in.available()];
            int len = 0;
            int temp = 0;                             //所有读取的内容都使用temp接收
            while ((temp = in.read()) != -1) {            //当没有读取完时,继续读取
                fileBuffer[len] = (byte) temp;
                len++;
            ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
            byte[] buff = new byte[BUFFER_SIZE]; //buff用于存放循环读取的临时数据
            int rc = 0;
            while ((rc = in.read(buff, 0, BUFFER_SIZE)) > 0) {
                swapStream.write(buff, 0, rc);
            }
            in.close();
            byte[] fileBuffer = swapStream.toByteArray(); //in_b为转换之后的结果
            TrackerServer trackerServer = FastDFSClientPool.getInstance().getTrackerServer();

+ 3 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -302,10 +302,10 @@ public class WechatController extends WeixinBaseController {
            password = RSAUtils.getInstance(patientService).decryptString(password);
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
            patient.setOpenid(openid);
            JSONObject json = patientService.register(patient, openid, 3);
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    , salt, openid, 3);
            if (json != null) {
                // 注册成功
                return write(200, "注册成功!", "data", json);
@ -334,6 +334,7 @@ public class WechatController extends WeixinBaseController {
            @RequestParam(required = false) String captcha,
            @RequestParam(required = false) String password,
            String openid) {
        System.out.println("login openid : " + openid );
        String errorMessage;
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());

+ 5 - 14
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java

@ -192,6 +192,7 @@ public class WlyySerivceController extends BaseController{
        }
    }
    /**
     * 转诊预约医生特殊号源获取
     * @param OrgCode 医院编号
@ -203,26 +204,16 @@ public class WlyySerivceController extends BaseController{
    @ApiOperation("转诊预约获取特殊号源接口")
    public String getSpeDoctorSectionList(@RequestParam("OrgCode") String OrgCode,@RequestParam("DeptCode") String DeptCode,@RequestParam("DocCode") String DocCode){
        try{
            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
            Date nowDate =new Date();
            Date tenDateAfter =  getDateAfter(nowDate,10);
            String strStart = sm.format(nowDate);
            String strEnd = sm.format(tenDateAfter);
            //String response = jwSmjkService.getRegDeptSpeDoctorSectionList(OrgCode,DeptCode,strStart,strEnd,DocCode);
            List<Map<String,Object>> list = guahaoXM.GetDoctorArrangeTenDay(OrgCode,DeptCode,DocCode);
            return write(200, "获取医生排班成功!", "data", list);
            /*****modify by linz 暂时把号源转换成普通号源****/
           /* *//*****modify by linz 暂时把号源转换成普通号源****//*
            List<Map<String,Object>> list =  guahaoXM.GetDoctorArrange(OrgCode,DeptCode,DocCode);
            //if(StringUtils.isEmpty(response)){
            //    return write(-1,"医生排班时间获取失败");
            //}else{
            //    JSONObject myJsonObject = new JSONObject(jsonString);
            //    return write(200,"医生排班时间获取成功","data",parseXmlForSpe(response));
            //}
            for(Map map :list){
                String date = (String)map.get("date");
                map.put("date",date.replaceAll("-","/"));
            }
            return write(200, "获取医生排班成功!", "data", list);
            return write(200, "获取医生排班成功!", "data", list);*/
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"医生排班时间获取失败");

+ 34 - 18
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -100,12 +100,12 @@ public class DoctorFollowUpController extends BaseController {
	@ResponseBody
	public String editFollowupPlan(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
								@RequestParam(value="id",required = true) String id,
								@ApiParam(name="date",value="随访时间",defaultValue = "2016-12-14 20:00:00")
								@RequestParam(value="date",required = true) String date,
								@ApiParam(name="planDate",value="随访计划时间",defaultValue = "2016-12-14 20:00:00")
								@RequestParam(value="planDate",required = true) String planDate,
								@ApiParam(name="followupType",value="随访方式【字典FOLLOWUP_WAY_DICT】",defaultValue = "12")
								@RequestParam(value="followupType",required = true) String followupType) {
		try {
			followUpService.editFollowupPlan(getUID(),id,date,followupType);
			followUpService.editFollowupPlan(getUID(),id,planDate,followupType);
			return write(200, "编辑随访计划成功!");
		} catch (Exception e) {
@ -187,7 +187,7 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	/*********************************** 随访详情 *******************************************************************/
	@ApiOperation("获取面访信息")
	@ApiOperation("获取随访信息")
	@RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowup(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
@ -196,13 +196,13 @@ public class DoctorFollowUpController extends BaseController {
		try {
			Map<String,String> response = followUpService.getFollowup(id);
			return write(200, "获取面访信息成功!","data",response);
			return write(200, "获取随访信息成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访信息失败!"+e.getMessage());
			return invalidUserException(e, -1, "获取随访信息失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取面访项目列表")
	@ApiOperation("获取随访项目列表")
	@RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupProject(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
@ -211,46 +211,62 @@ public class DoctorFollowUpController extends BaseController {
		try {
			List<Map<String,String>> list = followUpService.getFollowupProject(id);
			return write(200, "获取面访项目列表成功!","data",list);
			return write(200, "获取随访项目列表成功!","data",list);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访项目列表失败!"+e.getMessage());
			return invalidUserException(e, -1, "获取随访项目列表失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取面访项目数据")
	@ApiOperation("获取随访项目数据")
	@RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
									 @RequestParam(value="id",required = true) String id,
									 @ApiParam(name="followupProject",value="面访项目",defaultValue = "2")
									 @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
									 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			Map<String,String> response = followUpService.getFollowupProjectData(id,followupProject);
			return write(200, "获取面访项目数据成功!","data",response);
			return write(200, "获取随访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访项目数据失败!"+e.getMessage());
			return invalidUserException(e, -1, "获取随访项目数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("获取上次随访项目数据")
	@RequestMapping(value = "/getLastFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowupProjectData(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
										 @RequestParam(value="patient",required = true) String patient,
										 @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
										 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowupProjectData("D20161008003",patient,followupProject);
			return write(200, "获取上次随访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访项目数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存面访项目数据")
	@ApiOperation("保存随访项目数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String saveFollowupProjectData(@ApiParam(name="id",value="随访记录ID",defaultValue = "4")
								   @RequestParam(value="id",required = true) String id,
								   @ApiParam(name="followupProject",value="面访项目",defaultValue = "2")
								   @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
								   @RequestParam(value="followupProject",required = true) String followupProject,
								   @ApiParam(name="followupProjectData",value="面访项目数据",defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
								   @ApiParam(name="followupProjectData",value="随访项目数据",defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
								   @RequestParam(value="followupProjectData",required = true) String followupProjectData)
	{
		try {
			followUpService.saveFollowupProjectData(id,followupProject,followupProjectData);
			return write(200, "保存面访项目数据成功!");
			return write(200, "保存随访项目数据成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "保存面访项目数据失败!"+e.getMessage());
			return invalidUserException(e, -1, "保存随访项目数据失败!"+e.getMessage());
		}
	}

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -201,7 +201,8 @@ public class SignPatientLabelInfoController extends BaseController {
    public String getAmountByTeam(@RequestParam(required = true) Long teamCode) {
        try {
            int result = labelInfoService.getPatientAmountByTeam(teamCode);
            return write(200, "查询成功", "data", result);
            int resultFocus =labelInfoService.getPatientFocusAmountByTeam(teamCode);
            return write(200, "查询成功", "data", resultFocus + "/" + result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }

+ 113 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java

@ -0,0 +1,113 @@
package com.yihu.wlyy.web.doctor.reply;
import com.fasterxml.jackson.databind.deser.Deserializers;
import com.yihu.wlyy.entity.doctor.reply.DoctorQuickReply;
import com.yihu.wlyy.service.app.reply.DoctorQuickReplyService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * Created by lyr-pc on 2016/12/28.
 */
@RestController
@RequestMapping(value = "/doctor/reply")
@Api(description = "医生快捷回复")
public class DoctorQuickReplyController extends BaseController {
    @Autowired
    DoctorQuickReplyService quickReplyService;
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加快捷回复")
    public String addReply(@RequestParam @ApiParam(value = "快捷回复内容") String content) {
        try {
            if (StringUtils.isEmpty(content)) {
                return error(-1, "快捷回复内容不能为空");
            }
            DoctorQuickReply reply = quickReplyService.addReply(getUID(), content);
            if (reply != null) {
                return write(200, "添加成功", "data", reply);
            } else {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除快捷回复")
    public String delReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id) {
        try {
            if (id == null || id < 1) {
                return error(-1, "请选择需删除的快捷回复");
            }
            int result = quickReplyService.delReply(getUID(), id);
            if (result == 1) {
                return write(200, "删除成功");
            } else if (result == -1) {
                return error(-1, "快捷回复不存在或已删除");
            } else {
                return error(-1, "删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }
    @RequestMapping(value = "/sort", method = RequestMethod.POST)
    @ApiOperation(value = "快捷回复排序")
    public String sortReply(@RequestParam @ApiParam(value = "快捷回复ID")Long id,
                            @RequestParam @ApiParam(value = "排序位置")Integer sort) {
        try {
            if (id == null || id < 1) {
                return error(-1, "请选择排序的快捷回复");
            }
            if (sort == null || sort < 1) {
                return error(-1, "请设置快捷回复的排序位置");
            }
            int result = quickReplyService.sortReply(getUID(), id, sort);
            if (result == 1) {
                return write(200, "排序成功");
            } else if (result == -1) {
                return error(-1, "快捷回复不存在或已删除");
            }  else if (result == -2) {
                return error(-1, "快捷回复已在排序位置");
            } else {
                return error(-1, "排序失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "排序失败");
        }
    }
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "快捷回复列表")
    public String replyList() {
        try {
            List<DoctorQuickReply> replies = quickReplyService.getDoctorReplyList(getUID());
            return write(200, "查询成功", "data", replies);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 70 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -6,16 +6,18 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.sign.ExpensesRemindService;
import com.yihu.wlyy.service.app.sign.PatientRemindService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -60,7 +62,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    @Autowired
    MessageService messageService;
    @Autowired
    ExpensesRemindService expensesRemindService;
    PatientRemindService patientRemindService;
    @Autowired
    AdminTeamService teamService;
@ -814,7 +816,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "参数不能同时为空");
            }
            JSONObject result = familyContractService.updateSignInfo(patient, healthDoctor, doctor, expensesType,getUID());
            JSONObject result = familyContractService.updateSignInfo(patient, healthDoctor, doctor, expensesType, getUID());
            if (result.getInt("status") != 1) {
                return error(-1, result.getString("msg"));
@ -870,7 +872,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    /**
     * 获取没有健康管理师的签约数据数目
     *
     * @param doctor 医生code
     * @param teamCode 团队code
     * @return
     */
    @RequestMapping(value = "/findNoHealthSignFamilyNum")
@ -878,12 +880,13 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    public String findNoHealthSignFamilyNum(long teamCode) {
        try {
            List<SignFamily> signFamily = familyContractService.findNoHealthSignFamilyNum(teamCode);
            int count = familyContractService.findNoHealthSignFamilyFocusNum(teamCode);
            JSONObject jo = new JSONObject();
            if (signFamily != null && signFamily.size() > 0) {
                jo.put("date", DateUtil.dateToStr(signFamily.get(0).getCzrq(), "yyyy-MM-dd"));
                jo.put("num", signFamily.size());
                jo.put("num", count + "/" + signFamily.size());
            } else {
                jo.put("num", 0);
                jo.put("num", "0/0");
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
@ -906,17 +909,33 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            if (StringUtils.isEmpty(patient) && StringUtils.isEmpty(isAll)) {
                return error(-1, "参数不能都为空");
            }
            String status = redisTemplate.opsForValue().get("expenses:remind:doctor:" + getUID());
            status = StringUtils.isEmpty(status) ? "0" : status;
            if (!status.equals("1")) {
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "1");
                redisTemplate.expire("expenses:remind:doctor:" + getUID(), 20, TimeUnit.MINUTES);
            } else {
                return error(-2, "正在提醒中,请勿重复操作");
            }
            if (StringUtils.isNotEmpty(patient)) {
                JSONObject result = expensesRemindService.remindPatientExpenses(patient, getUID());
                JSONObject result = patientRemindService.remindPatientExpenses(patient, getUID());
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
                redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
                return write(result.getInt("status"), result.getString("msg"));
            } else if (StringUtils.isNotEmpty(isAll) && isAll.equals("1")) {
                expensesRemindService.remindPatientExpensesAll(getUID());
                patientRemindService.remindPatientExpensesAll(getUID());
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
                redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
                return error(200, "提醒操作成功");
            } else {
                redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
                redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
                return write(-1, "参数错误");
            }
        } catch (Exception e) {
            redisTemplate.opsForValue().set("expenses:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("expenses:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "提醒失败");
        }
@ -1038,4 +1057,46 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/wechat_focus_remind", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "微信关注提醒")
    public String wechatFocusRemind(@RequestParam(defaultValue = "") @ApiParam(value = "居民") String patient,
                                    @RequestParam(defaultValue = "") @ApiParam(value = "是否全部(1:全部  0:非全部)") String isAll) {
        try {
            int result = 1;
            String msg = "提醒成功";
            String status = redisTemplate.opsForValue().get("wechat:focus:remind:doctor:" + getUID());
            status = StringUtils.isEmpty(status) ? "0" : status;
            if (!status.equals("1")) {
                redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "1");
                redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 20, TimeUnit.MINUTES);
            } else {
                result = -1;
                msg = "正在提醒中,请勿重复操作";
            }
            if (isAll.equals("1")) {
                patientRemindService.remindPatientWechatFocusAll(getUID());
            } else {
                if (StringUtils.isEmpty(patient)) {
                    result = -1;
                    msg = "请选择需提醒的居民";
                }
                JSONObject json = patientRemindService.remindPatientFocusWechat(patient, getUID());
                result = json.getInt("status");
                msg = json.getString("msg");
            }
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            return write(result, msg);
        } catch (Exception e) {
            redisTemplate.opsForValue().set("wechat:focus:remind:doctor:" + getUID(), "0");
            redisTemplate.expire("wechat:focus:remind:doctor:" + getUID(), 10, TimeUnit.MINUTES);
            e.printStackTrace();
            return error(-1, "微信关注提醒失败");
        }
    }
}

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

@ -268,6 +268,19 @@ public class DoctorSignController extends BaseController {
                            json.put("expensesRemindStatus", df.format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    if (status == 3) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + temp.get("patient"));
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("wechatFocusRemind", 0);
                        } else {
                            json.put("wechatFocusRemind", df.format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                    jsonArray.add(json);
                }
            }

+ 68 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.config.FastDFSConfig;
import com.yihu.wlyy.service.app.archives.PatientEventService;
import com.yihu.wlyy.service.app.archives.PatientRecordService;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
@ -166,7 +167,7 @@ public class PatientArchivesController extends WeixinBaseController {
    @ResponseBody
    @ApiOperation("删除就诊事件")
    public String deleteEvent(@ApiParam(name="event",value="就诊事件id",defaultValue = "")
                                  @RequestParam(value="event",required = true) String event)
                                  @RequestParam(value="event",required = true) Long event)
    {
        try {
            patientEventService.deleteEvent(event);
@ -180,23 +181,23 @@ public class PatientArchivesController extends WeixinBaseController {
    @RequestMapping(value = "/event/uploadImg", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("单张上传图片")
    public String uploadImg(@ApiParam(name="mediaId",value="微信图片标识",defaultValue = "")
                            @RequestParam(value="mediaId",required = true) String mediaId,
                            @ApiParam(name="fileExt",value="文件格式后缀",defaultValue = "")
                            @RequestParam(value="fileExt",required = false) String fileExt)
    public String uploadImg(@ApiParam(name="mediaId",value="微信图片标识",defaultValue = "wL1vfE9g1fiRCl5xd-Xotl1XycWQ9mwigDLUv-S0Kmde-pXNrlySKbf5RM5SwwFl")
                            @RequestParam(value="mediaId",required = true) String mediaId)
    {
        try {
            String url ="";
            FastDFSUtil fastDFSUtil = new FastDFSConfig().fastDFSUtil();
            InputStream wxImg = getInputStream(mediaId);
            if(StringUtils.isEmpty(fileExt))
            {
                fileExt="jpg";
            }
            ObjectNode result = fastDFSUtil.upload(wxImg, fileExt, "");
            ObjectNode result = fastDFSUtil.upload(wxImg, "jpg", "");
            wxImg.close();
            String serverUrl = SystemConf.getInstance().getSystemProperties().getProperty("fastdfs_file_url");
            if (result != null) {
                url = result.get("fileUrl").toString().replaceAll("\"", "");
                url = serverUrl
                        + result.get("groupName").toString().replaceAll("\"", "") + "/"
                        + result.get("remoteFileName").toString().replaceAll("\"", "");
            }
            else{
                return write(-1, "图片上传失败!");
            }
            return write(200, "图片上传成功!","url", url);
@ -204,4 +205,60 @@ public class PatientArchivesController extends WeixinBaseController {
            return invalidUserException(e,-1, "图片上传失败!");
        }
    }
    @RequestMapping(value = "/event/img/delete", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("删除就诊事件图片")
    public String deleteEventImg(@ApiParam(name="id",value="就诊事件图片id",defaultValue = "")
                              @RequestParam(value="id",required = true) Long id)
    {
        try {
            patientEventService.deleteEventImg(id);
            return write(200, "删除就诊事件图片成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "删除就诊事件图片失败!");
        }
    }
    @RequestMapping(value = "/event/img/add", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("新增就诊事件图片")
    public String addEventImg(@ApiParam(name="eventId",value="就诊事件id",defaultValue = "")
                                 @RequestParam(value="eventId",required = true) Long eventId,
                              @ApiParam(name="imgType",value="图片类别",defaultValue = "")
                              @RequestParam(value="imgType",required = true) String imgType,
                              @ApiParam(name="imgLabel",value="图片标签",defaultValue = "")
                                  @RequestParam(value="imgLabel",required = true) String imgLabel,
                              @ApiParam(name="imgUrl",value="图片路径",defaultValue = "")
                                  @RequestParam(value="imgUrl",required = true) String imgUrl)
    {
        try {
            patientEventService.addEventImg(eventId,imgType,imgLabel,imgUrl);
            return write(200, "新增就诊事件图片成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "新增就诊事件图片失败!");
        }
    }
    @RequestMapping(value = "/event/img/edit", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("修改就诊事件图片")
    public String editEventImg(@ApiParam(name="id",value="就诊事件图片id",defaultValue = "")
                              @RequestParam(value="id",required = true) Long id,
                              @ApiParam(name="imgType",value="图片类别",defaultValue = "")
                              @RequestParam(value="imgType",required = true) String imgType,
                              @ApiParam(name="imgLabel",value="图片标签",defaultValue = "")
                              @RequestParam(value="imgLabel",required = true) String imgLabel)
    {
        try {
            patientEventService.editEventImg(id,imgType,imgLabel);
            return write(200, "修改就诊事件图片成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "修改就诊事件图片失败!");
        }
    }
}

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

@ -398,7 +398,7 @@ public class ConsultController extends WeixinBaseController {
            doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_03.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
            return success("提交成功");
            return write(200, "提交成功", "data", consult);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "提交失败!");

+ 72 - 79
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -20,6 +20,7 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
@ -71,8 +73,31 @@ public class BookingController extends WeixinBaseController {
    }
    /**
     * 获取机构列表
     * 发送短信参数
     */
    private static List<NameValuePair> buildSmsParams(String content, String mobile) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
        params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
        params.add(new BasicNameValuePair("Password", SystemConf.getInstance().getSmsPassword()));
        params.add(new BasicNameValuePair("MessageContent", content));
        params.add(new BasicNameValuePair("UserNumber", mobile));
        params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
        params.add(new BasicNameValuePair("ScheduleTime", ""));
        params.add(new BasicNameValuePair("f", "1"));
        return params;
    }
    /**
     * 获取前三个月时间
     */
    private static Date getMonthBefore(Date d, int month) {
        Calendar now = Calendar.getInstance();
        now.setTime(d);
        now.set(Calendar.MONTH, now.get(Calendar.MONTH) - month);
        return now.getTime();
    }
    @RequestMapping(value = "GetOrgList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取机构列表")
@ -95,9 +120,6 @@ public class BookingController extends WeixinBaseController {
    }
    /**
     * 获取科室接口
     */
    @RequestMapping(value = "GetOrgDepList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取科室接口")
@ -119,9 +141,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    /**
     * 获取医生列表接口
     */
    @RequestMapping(value = "GetDoctorList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取医生接口")
@ -145,9 +164,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    /**
     * 获取医生排班接口
     */
    @RequestMapping(value = "GetDoctorArrange", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取医生排班接口(包含排班详细)")
@ -167,9 +183,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    /**
     * 获取医生排班接口
     */
    @RequestMapping(value = "GetDoctorArrangeSimple", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取医生排班接口(一级)")
@ -189,9 +202,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    /**
     * 根据医生编码获取医生详细信息
     */
    @RequestMapping(value = "GetDoctorInfo", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("根据医生编码获取医生详细信息")
@ -211,9 +221,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    /**
     * 创建挂号单
     */
    @RequestMapping(value = "CreateOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("创建挂号单")
@ -256,7 +263,7 @@ public class BookingController extends WeixinBaseController {
            if (StringUtils.isEmpty(patientPhone)) {
                return error(-1, "未设置手机号码!");
            }
            String orderCode = getService(city).CreateOrder(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone, null, null);
            String orderCode = getService(city).CreateOrder(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone);
            //预约发送微信消息
            PatientReservation obj = patientReservationService.findByCode(orderCode);
@ -268,8 +275,9 @@ public class BookingController extends WeixinBaseController {
                    JSONObject json = new JSONObject();
                    json.put("first", "");
                    json.put("toUser", p.getCode());
                    json.put("id", obj.getId());
                    json.put("id", obj.getCode());
                    json.put("date", obj.getStartTime());
                    json.put("orgCode", obj.getOrgCode());
                    json.put("orgName", obj.getOrgName());
                    json.put("doctorName", obj.getDoctorName());
                    json.put("deptName", obj.getDeptName());
@ -297,58 +305,24 @@ public class BookingController extends WeixinBaseController {
        }
    }
    public static List<NameValuePair> buildSmsParams(String content, String mobile) {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
        params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
        params.add(new BasicNameValuePair("Password", SystemConf.getInstance().getSmsPassword()));
        params.add(new BasicNameValuePair("MessageContent", content));
        params.add(new BasicNameValuePair("UserNumber", mobile));
        params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
        params.add(new BasicNameValuePair("ScheduleTime", ""));
        params.add(new BasicNameValuePair("f", "1"));
        return params;
    }
    public static JSONObject toJson(String result) {
        JSONObject json = new JSONObject();
        try {
            String[] temps = result.split("&");
            for (String temp : temps) {
                if (temp.split("=").length != 2) {
                    continue;
                }
                String key = temp.split("=")[0];
                String value = temp.split("=")[1];
                json.put(key, value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return json;
    }
    /**
     * 创建挂号单
     */
    @RequestMapping(value = "CreateOrderByDoctor", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("创建挂号单")
    public String CreateOrderByDoctor(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
                                      @RequestParam(value = "city", required = true) String city,
                                      @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
    @ApiOperation("(内网)转诊预约挂号")
    public String CreateOrderByDoctor(@ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
                                      @RequestParam(value = "hospitalId", required = true) String hospitalId,
                                      @ApiParam(name = "hospitalName", value = "医院名称", defaultValue = "厦门大学附属第一医院")
                                      @RequestParam(value = "hospitalName", required = true) String hospitalName,
                                      @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1040610")
                                      @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
                                      @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
                                      @ApiParam(name = "hosDeptName", value = "医院科室名称", defaultValue = "儿二科")
                                      @ApiParam(name = "hosDeptName", value = "医院科室名称", defaultValue = "内分泌糖尿病科门诊")
                                      @RequestParam(value = "hosDeptName", required = true) String hosDeptName,
                                      @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "07101")
                                      @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
                                      @RequestParam(value = "doctorId", required = true) String doctorId,
                                      @ApiParam(name = "doctorName", value = "医生姓名", defaultValue = "林素莲")
                                      @ApiParam(name = "doctorName", value = "医生姓名", defaultValue = "杨叔禹")
                                      @RequestParam(value = "doctorName", required = true) String doctorName,
                                      @ApiParam(name = "arrangeDate", value = "排班信息", defaultValue = "{\"sectionType\":\"a\",\"startTime\":\"2016-09-02 08:20:00\",\"endTime\":\"2016-09-02 08:30:00\"}")
                                      @ApiParam(name = "arrangeDate", value = "排班信息", defaultValue = "{\"sectionType\":\"p\",\"startTime\":\"2016-12-29 14:00:00\",\"endTime\":\"2016-12-29 14:08:00\"}")
                                      @RequestParam(value = "arrangeDate", required = true) String arrangeDate,
                                      @ApiParam(name = "patient", value = "患者代码", defaultValue = "01954b2ebbb24a40a05da9d2f5c94795")
                                      @RequestParam(value = "patient", required = true) String patient,
@ -356,7 +330,7 @@ public class BookingController extends WeixinBaseController {
                                      @RequestParam(value = "patientName", required = true) String patientName,
                                      @ApiParam(name = "cardNo", value = "身份证号码", defaultValue = "35052419880511553X")
                                      @RequestParam(value = "cardNo", required = true) String cardNo,
                                      @ApiParam(name = "clinicCard", value = "市民卡号", defaultValue = "D57117706")
                                      @ApiParam(name = "clinicCard", value = "市民卡号", defaultValue = "A0601003595X")
                                      @RequestParam(value = "clinicCard", required = true) String clinicCard,
                                      @ApiParam(name = "patientPhone", value = "患者手机", defaultValue = "13950116510")
                                      @RequestParam(value = "patientPhone", required = true) String patientPhone,
@ -377,7 +351,7 @@ public class BookingController extends WeixinBaseController {
            if (StringUtils.isEmpty(patientPhone)) {
                return error(-1, "未设置手机号码!");
            }
            String orderCode = getService(city).CreateOrder(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
            String orderCode = guahaoXM.CreateOrderByDoctor(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
            //获取预约信息查询是否挂号成功
            PatientReservation obj = patientReservationService.findByCode(orderCode);
            if (obj != null) {
@ -390,9 +364,10 @@ public class BookingController extends WeixinBaseController {
                    JSONObject json = new JSONObject();
                    json.put("first", "");
                    json.put("toUser", p.getCode());
                    json.put("id", obj.getId());
                    json.put("id", obj.getCode());
                    json.put("date", obj.getStartTime());
                    json.put("orgName", obj.getOrgName());
                    json.put("orgCode", obj.getOrgCode());
                    json.put("doctorName", obj.getDeptName());
                    json.put("deptName", obj.getDeptName());
                    json.put("remark", p.getName() + ",您好!\n" + msg);
@ -411,6 +386,23 @@ public class BookingController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "GetDoctorArrangeTenDay", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("(内网)获取医生排班接口")
    public String GetDoctorArrangeTenDay(
                                   @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
                                   @RequestParam(value = "hospitalId", required = true) String hospitalId,
                                   @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
                                   @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
                                   @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
                                   @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            List<Map<String, Object>> list = guahaoXM.GetDoctorArrangeTenDay(hospitalId, hosDeptId, doctorId);
            return write(200, "获取医生排班成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    /**
     * 取消挂号单
@ -462,9 +454,7 @@ public class BookingController extends WeixinBaseController {
    }
    /**
     * 获取患者预约信息列表接口
     */
    @RequestMapping(value = "GetPatientReservationList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取患者预约信息列表接口-医生端")
@ -500,9 +490,7 @@ public class BookingController extends WeixinBaseController {
        }
    }
    /**
     * 获取医生代预约信息列表接口
     */
    @RequestMapping(value = "GetDoctorReservationList", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取医生代预约信息列表接口-医生端")
@ -515,9 +503,21 @@ public class BookingController extends WeixinBaseController {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByDoctor(doctor, pageIndex, pageSize);
            //遍历更新预约状态
            JSONArray array = new JSONArray();
            for (PatientReservation item : list) {
                String type = item.getType();
                String code = item.getCode();
                JSONObject object = new JSONObject();
                Class pClass = (Class) item.getClass();
                for(Field field  : pClass.getDeclaredFields()){
                    field.setAccessible(true);
                    object.put(field.getName(),field.get(item));
                }
                Patient patient = patientService.findByCode(item.getPatient());
                if(patient!=null){
                    object.put("photo",patient.getPhoto());
                }
                array.put(object);
                if (type.equals("0")) {  //医护网接口
                } else if (type.equals("1"))   //厦门市民健康预约接口
@ -530,7 +530,7 @@ public class BookingController extends WeixinBaseController {
                    }
                }
            }
            return write(200, "获取患者预约信息列表成功!", "data", list);
            return write(200, "获取患者预约信息列表成功!", "data", array);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
@ -556,13 +556,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    public static Date getMonthBefore(Date d, int month) {
        Calendar now = Calendar.getInstance();
        now.setTime(d);
        now.set(Calendar.MONTH, now.get(Calendar.MONTH) - month);
        return now.getTime();
    }
    /**
     * 获取患者预约信息单条
     */

+ 15 - 5
patient-co-wlyy/src/main/resources/application.properties

@ -4,11 +4,21 @@
#jdbc.url=jdbc:mysql://59.61.92.94:3306/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
#jdbc.username=wlyy
#jdbc.password=jkzlehr@123
#
#fv.jdbc.driver=com.mysql.jdbc.Driver
#fv.jdbc.url=jdbc:mysql://172.19.103.85/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=root
#fv.jdbc.password=123456
#fv.jdbc.url=jdbc:mysql://59.61.92.94:3306/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=wlyy
#fv.jdbc.password=jkzlehr@123
#
#health.jdbc.driver=com.mysql.jdbc.Driver
#health.jdbc.url=jdbc:mysql://59.61.92.94:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#health.jdbc.username=wlyy
#health.jdbc.password=jkzlehr@123
#
#
#redis.host=120.41.253.95
#redis.port=6380
#redis.password=jkzl_ehr
####--------------IMPORTANT!!! DEMO ENVIRONMENT------------------#####
#mysql database setting
@ -41,7 +51,7 @@
#redis.maxWait=1000
#redis.testOnBorrow=true
#------------------------------------开发环境数据库配置------------------------------------#
##------------------------------------开发环境数据库配置------------------------------------#
#### mysql database setting
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true

+ 1 - 0
patient-co-wlyy/src/main/resources/applicationContext.xml

@ -122,6 +122,7 @@
	<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
		<property name="hostName" value="${redis.host}"></property>
		<property name="port" value="${redis.port}"></property>
		<property name="password" value="${redis.password}"></property>
		<property name="poolConfig" ref="poolConfig"></property>
	</bean>

+ 2 - 2
patient-co-wlyy/src/main/resources/config/fdfs_client.conf

@ -9,7 +9,7 @@ http.secret_key = FastDFS1234567890
tracker_server = 172.19.103.54:22122
#-------------测试环境---------------#
#tracker_server = 172.19.103.13:22122
#tracker_server = 172.19.103.54:22122
#-------------正式环境---------------#
#tracker_server = 192.168.0.239:23000
#tracker_server = 192.168.0.239:22122

+ 1 - 1
patient-co-wlyy/src/main/resources/system.properties

@ -17,7 +17,7 @@ doctor_hos_qrcode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid=
doctor_subscribe_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2fsigning-welcome.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
doctor_town_qrcode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2fsearch-community.html&amp;response_type=code&amp;scope=snsapi_base&amp;state={town}#wechat_redirect
doctor_qrcode_pic_url={server}/images/familycontract.png
doctor_invitel_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&redirect_uri={server}%2fwx%2fhtml%2fssgg%2fhtml%2fdoctor-homepage-new.html&response_type=code&scope=snsapi_base&state={doctorCode}__{invilogcode}__{currentPatient}__{currentZH}#wechat_redirect
doctor_invitel_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&redirect_uri={server}%2fwx%2fhtml%2fssgg%2fhtml%2fdoctor-homepage-new.html&response_type=code&scope=snsapi_base&state={doctorCode}__{invilogcode}__{currentPatient}__{currentZH}__{currentName}#wechat_redirect
# SMS短信配置
yihu_sms_url=https://smsapi.ums86.com:9600/sms/Api/Send.do

+ 10 - 0
patient-co-wlyy/src/main/resources/weixin_menu.txt

@ -43,6 +43,16 @@
			"type":"view",
			"name":"健康记录",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkjl%2fhtml%2fhealth-record.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
		{
			"type":"view",
			"name":"就诊记录",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkda%2fhtml%2fjiuzhenjilu.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
		{
			"type":"view",
			"name":"检查检验",
			"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkda%2fhtml%2fjianchajianyan.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		}
	  ]
   },