Browse Source

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

DESKTOP-G6NQ3SI\dante 7 years ago
parent
commit
3dcf836076
77 changed files with 4171 additions and 462 deletions
  1. 2 2
      common/common-entity/src/main/java/com/yihu/device/entity/DevicePatientHealthIndex.java
  2. 9 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/address/Country.java
  3. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java
  4. 15 8
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodPressure.java
  5. 13 4
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodSugger.java
  6. 50 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodPressureVO.java
  7. 50 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodSuggerVO.java
  8. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/SignPatientLabel.java
  9. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java
  10. 6 6
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java
  11. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java
  12. 37 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionPay.java
  13. 138 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/ylz/PayConfigura.java
  14. 31 35
      patient-co/patient-co-figure/src/main/java/com/yihu/figure/controller/patient/PortraitController.java
  15. 2 1
      patient-co/patient-co-statistics/src/main/resources/application.yml
  16. 9 9
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java
  17. 18 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  18. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java
  19. 255 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorFeldsherTemplateJob.java
  20. 57 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayQueryJob.java
  21. 27 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientSchemeListDao.java
  22. 10 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionPayDao.java
  23. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/ylz/PayConfiguraDao.java
  24. 249 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  25. 122 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java
  26. 39 3
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  27. 4 4
      patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml
  28. 5 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  29. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  30. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/address/CountryDao.java
  31. 24 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java
  32. 15 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodSuggerDao.java
  33. 29 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctroSchemeBloodSuggerDao.java
  34. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientAimSportsDao.java
  35. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/scheme/PatientSchemeListDao.java
  36. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java
  37. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java
  38. 17 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/ylz/PayConfiguraDao.java
  39. 56 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  40. 36 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  41. 590 52
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  42. 281 105
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  43. 19 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  44. 372 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java
  45. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  46. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/DoctorService.java
  47. 10 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  48. 275 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java
  49. 265 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java
  50. 144 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java
  51. 0 129
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java
  52. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/model/BindCard.java
  53. 114 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  54. 22 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java
  55. 31 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  56. 54 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java
  57. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java
  58. 7 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  59. 77 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java
  60. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  61. 135 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  62. 64 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  63. 80 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  64. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  65. 116 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java
  66. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  67. 69 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorFeldsherTemplateController.java
  68. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  69. 6 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  70. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java
  71. 3 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java
  72. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java
  73. 5 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java
  74. 1 7
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  75. 0 8
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  76. 0 6
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml
  77. 1 1
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

+ 2 - 2
common/common-entity/src/main/java/com/yihu/device/entity/DevicePatientHealthIndex.java

@ -25,9 +25,9 @@ public class DevicePatientHealthIndex extends IdEntity {
	private String value1;
	// 舒张压/早餐后空腹/身高
	private String value2;
	// 午餐空腹/身高
	// 午餐空腹/BMI
	private String value3;
	// 午餐后
	// 午餐后/偏胖-1/正常0/偏瘦1
	private String value4;
	// 晚餐空腹
	private String value5;

+ 9 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/address/Country.java

@ -17,6 +17,7 @@ public class Country extends IdEntity {
    private String  street ;
    private String  code;
    private String  name;
    private String  jwCode;
    public String getProvince() {
        return province;
@ -65,4 +66,12 @@ public class Country extends IdEntity {
    public void setCode(String code) {
        this.code = code;
    }
    public String getJwCode() {
        return jwCode;
    }
    public void setJwCode(String jwCode) {
        this.jwCode = jwCode;
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/profile/Doctor.java

@ -70,6 +70,8 @@ public class Doctor extends IdEntity {
    private Date certifiedOvertime; //CA证书过期时间
    private String certificateNum;     //CA证书编号
    private String openid; //医生微信openID
    public Double getEvaluateScore() {
        return evaluateScore;
    }
@ -428,4 +430,12 @@ public class Doctor extends IdEntity {
    public void setCertificateNum(String certificateNum) {
        this.certificateNum = certificateNum;
    }
    public String getOpenid() {
        return openid;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
}

+ 15 - 8
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodPressure.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.entity.doctor.scheme;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
@ -14,10 +15,10 @@ import java.sql.Timestamp;
@Entity
@Table(name = "wlyy_doctor_scheme_blood_pressure")
public class DoctorSchemeBloodPressure extends IdEntity {
    private String name;
    private String name;                //方案名称
    private String code;
    private String doctorcode;
    private short dayofweek;
    private String doctorcode;          //医生CODE
    private Short dayofweek;            //星期几
    private Short earlyMorning;
    private Time earlyMorningTime;
    private Short morning;
@ -28,9 +29,9 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    private Time afterNoonTime;
    private Short night;
    private Time nightTime;
    private Timestamp createTime;
    private Short alertTag;
    private String content;
    private Timestamp createTime;      //创建时间
    private Short alertTag;            //是否提醒用户
    private String content;            //方案说明
    @Basic
    @Column(name = "name")
@ -64,11 +65,11 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Column(name = "dayofweek")
    public short getDayofweek() {
    public Short getDayofweek() {
        return dayofweek;
    }
    public void setDayofweek(short dayofweek) {
    public void setDayofweek(Short dayofweek) {
        this.dayofweek = dayofweek;
    }
@ -84,6 +85,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Column(name = "early_morning_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getEarlyMorningTime() {
        return earlyMorningTime;
    }
@ -104,6 +106,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Column(name = "morning_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getMorningTime() {
        return morningTime;
    }
@ -124,6 +127,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Column(name = "noon_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getNoonTime() {
        return noonTime;
    }
@ -144,6 +148,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Column(name = "after_noon_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterNoonTime() {
        return afterNoonTime;
    }
@ -164,6 +169,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Column(name = "night_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getNightTime() {
        return nightTime;
    }
@ -174,6 +180,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    @Basic
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Timestamp getCreateTime() {
        return createTime;
    }

+ 13 - 4
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodSugger.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.entity.doctor.scheme;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
@ -14,10 +15,10 @@ import java.sql.Timestamp;
@Entity
@Table(name = "wlyy_doctor_scheme_blood_sugger")
public class DoctorSchemeBloodSugger extends IdEntity {
    private String name;
    private String name;                    //方案名称
    private String code;
    private String doctorcode;
    private Short dayofweek;
    private Short dayofweek;                //星期几:1-7,1代表周日,7代表周六
    private Short beforeBreakfast;
    private Time beforeBreakfastTime;
    private Short afterBreakfast;
@ -33,8 +34,8 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    private Short beforeSleep;
    private Time beforeSleepTime;
    private Timestamp createTime;
    private Short alertTag;
    private String content;
    private Short alertTag;                 //是否提醒用户
    private String content;                 //方案说明
    @Basic
    @Column(name = "name")
@ -88,6 +89,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "before_breakfast_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeBreakfastTime() {
        return beforeBreakfastTime;
    }
@ -108,6 +110,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "after_breakfast_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterBreakfastTime() {
        return afterBreakfastTime;
    }
@ -128,6 +131,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "before_lunch_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeLunchTime() {
        return beforeLunchTime;
    }
@ -148,6 +152,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "after_lunch_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterLunchTime() {
        return afterLunchTime;
    }
@ -168,6 +173,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "before_dinner_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeDinnerTime() {
        return beforeDinnerTime;
    }
@ -188,6 +194,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "after_dinner_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterDinnerTime() {
        return afterDinnerTime;
    }
@ -208,6 +215,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "before_sleep_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeSleepTime() {
        return beforeSleepTime;
    }
@ -218,6 +226,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    @Basic
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Timestamp getCreateTime() {
        return createTime;
    }

+ 50 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodPressureVO.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.entity.doctor.scheme.vo;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import java.util.List;
/**
 * 医生血压监测VO类
 * @author huangwenjie
 * @date 2017/9/13 21:28
 */
public class DoctorSchemeBloodPressureVO {
    private String                          code;
    private String                          name;       //名字
    private String                          content;    //说明
    private List<DoctorSchemeBloodPressure> list;       //详情
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public List<DoctorSchemeBloodPressure> getList() {
        return list;
    }
    public void setList(List<DoctorSchemeBloodPressure> list) {
        this.list = list;
    }
}

+ 50 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/vo/DoctorSchemeBloodSuggerVO.java

@ -0,0 +1,50 @@
package com.yihu.wlyy.entity.doctor.scheme.vo;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import java.util.List;
/**
 * 医生血糖VO类
 * @author huangwenjie
 * @date 2017/9/13 21:40
 */
public class DoctorSchemeBloodSuggerVO {
    private String                          code;
    private String                          name;       //名字
    private String                          content;    //说明
    private List<DoctorSchemeBloodSugger> list;       //详情
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public List<DoctorSchemeBloodSugger> getList() {
        return list;
    }
    public void setList(List<DoctorSchemeBloodSugger> list) {
        this.list = list;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/SignPatientLabel.java

@ -16,7 +16,7 @@ public class SignPatientLabel extends IdEntity {
    private String labelCode;
    // 标签名称
    private String labelName;
    // 标签类型 1:卫计委三大分组 2:健康情况 3:疾病类型 4:自定义
    // 标签类型 1:服务类型 2:健康情况 3:疾病类型 4:自定义
    private String labelType;
    // 是否系统标签
    private Integer isSystem;

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/Patient.java

@ -72,7 +72,7 @@ public class Patient extends IdEntity implements Serializable {
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	// 病情:0绿标,1黄标,2红标,3重点关注
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
	private Integer recordAmount;

+ 6 - 6
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java

@ -13,12 +13,12 @@ import java.sql.Timestamp;
@Entity
@Table(name = "wlyy_patient_aim_sports")
public class PatientAimSports extends IdEntity {
    private String code;
    private String patientcode;
    private Integer dailyStepCount;
    private String bmiMax;
    private String bmiMin;
    private Timestamp createTime;
    private String code;                //业务逻辑CODE,如果CODE为default,则该条记录为系统预置数据
    private String patientcode;         //患者CODE
    private Integer dailyStepCount;     //运动步数
    private String bmiMax;              //bmi标准上限
    private String bmiMin;              //bmi标准下线
    private Timestamp createTime;       //创建时间
    @Basic

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java

@ -16,7 +16,7 @@ public class PatientSchemeList extends IdEntity {
    private String code;
    private String patientcode;
    private String schemecode;
    private Short type;
    private Short type;//方案类型:0为血压,1为血糖
    private String doctorcode;
    private Timestamp createTime;

+ 37 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionPay.java

@ -58,6 +58,43 @@ public class PrescriptionPay extends IdEntity {
    private String mxlist;//处方明细
    private Date createTime;//续方确认支付时间
    private Date czrq;//续方记录最后操作时间
    //    易联众新增查询返回字段v1.3.7
    private String medOrgNo;//医疗机构编号
    private String medOrgName;//医疗机构名称
    private Date traceTime;//交易成功时间
    private String traceNo;//支付平台跟踪号
    public Date getTraceTime() {
        return traceTime;
    }
    public void setTraceTime(Date traceTime) {
        this.traceTime = traceTime;
    }
    public String getTraceNo() {
        return traceNo;
    }
    public void setTraceNo(String traceNo) {
        this.traceNo = traceNo;
    }
    public String getMedOrgNo() {
        return medOrgNo;
    }
    public void setMedOrgNo(String medOrgNo) {
        this.medOrgNo = medOrgNo;
    }
    public String getMedOrgName() {
        return medOrgName;
    }
    public void setMedOrgName(String medOrgName) {
        this.medOrgName = medOrgName;
    }
    public Integer getAccountBalance() {
        return accountBalance;

+ 138 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/ylz/PayConfigura.java

@ -0,0 +1,138 @@
package com.yihu.wlyy.entity.ylz;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * 易联众支付相关配置参数
 * Created by Reece on 2017/9/9/009.
 */
@Entity
@Table(name = "ylz_pay_config")
public class PayConfigura extends IdEntity implements Serializable {
    //    基础配置参数
    private String onepayApi ;
    private String onepayAppId;
    private String onepayAppSecret;
    private int del; //配置状态 0无效 1有效
    //社保卡绑定及查询
    private String bindCardType;
    private String createSicardType;
    //家庭签约支付
    private String chargeType;
    private String chargeQueryType;
    private String receiveNotify;
    private String returnUrl;
    //续方长处方支付
    private String recipeChargeType;
    private String recipeReturnUrl;
    private String receiveRecipeNotify;
    public int getDel() {
        return del;
    }
    public void setDel(int del) {
        this.del = del;
    }
    public String getOnepayApi() {
        return onepayApi;
    }
    public void setOnepayApi(String onepayApi) {
        this.onepayApi = onepayApi;
    }
    public String getOnepayAppId() {
        return onepayAppId;
    }
    public void setOnepayAppId(String onepayAppId) {
        this.onepayAppId = onepayAppId;
    }
    public String getOnepayAppSecret() {
        return onepayAppSecret;
    }
    public void setOnepayAppSecret(String onepayAppSecret) {
        this.onepayAppSecret = onepayAppSecret;
    }
    public String getBindCardType() {
        return bindCardType;
    }
    public void setBindCardType(String bindCardType) {
        this.bindCardType = bindCardType;
    }
    public String getCreateSicardType() {
        return createSicardType;
    }
    public void setCreateSicardType(String createSicardType) {
        this.createSicardType = createSicardType;
    }
    public String getChargeType() {
        return chargeType;
    }
    public void setChargeType(String chargeType) {
        this.chargeType = chargeType;
    }
    public String getChargeQueryType() {
        return chargeQueryType;
    }
    public void setChargeQueryType(String chargeQueryType) {
        this.chargeQueryType = chargeQueryType;
    }
    public String getReceiveNotify() {
        return receiveNotify;
    }
    public void setReceiveNotify(String receiveNotify) {
        this.receiveNotify = receiveNotify;
    }
    public String getReturnUrl() {
        return returnUrl;
    }
    public void setReturnUrl(String returnUrl) {
        this.returnUrl = returnUrl;
    }
    public String getRecipeChargeType() {
        return recipeChargeType;
    }
    public void setRecipeChargeType(String recipeChargeType) {
        this.recipeChargeType = recipeChargeType;
    }
    public String getRecipeReturnUrl() {
        return recipeReturnUrl;
    }
    public void setRecipeReturnUrl(String recipeReturnUrl) {
        this.recipeReturnUrl = recipeReturnUrl;
    }
    public String getReceiveRecipeNotify() {
        return receiveRecipeNotify;
    }
    public void setReceiveRecipeNotify(String receiveRecipeNotify) {
        this.receiveRecipeNotify = receiveRecipeNotify;
    }
}

+ 31 - 35
patient-co/patient-co-figure/src/main/java/com/yihu/figure/controller/patient/PortraitController.java

@ -1,11 +1,9 @@
package com.yihu.figure.controller.patient;
import com.yihu.figure.controller.BaseController;
import com.yihu.figure.model.dict.SystemDict;
import com.yihu.figure.model.patient.portrait.UserPortrait;
import com.yihu.figure.service.PortraitService;
import com.yihu.figure.service.dict.SystemDictService;
import com.yihu.figure.util.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -21,8 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -206,41 +202,41 @@ public class PortraitController extends BaseController {
    }
    private String getNameAgeByKey(String value,JSONObject return1) {
        DecimalFormat df   = new DecimalFormat("######0.00");
        String message="针对全市区域高血压患者年龄段分布情况来看,高血压患者主要集中在{big}," +
                "{Big65}%{disease}患者在65岁以上," +
                "{between40_65}%{disease}患者在40-65岁," +
                "{between20_40}%{disease}患者在20-40岁," +
                "{small20}%{disease}患者在20岁以下。";
        Double Big65=return1.getDouble("65岁以上");
        Double between40_65=return1.getDouble("40-65岁");
        Double between20_40=return1.getDouble("20-40岁");
        Double small20=return1.getDouble("20岁以下");
        message=message.replace("{Big65}",df.format(Big65*100));
        message=message.replace("{between40_65}",df.format(between40_65*100));
        message=message.replace("{between20_40}",df.format(between20_40*100));
        message=message.replace("{small20}",df.format(small20*100));
        if(Big65>between40_65&&Big65>between20_40&&Big65>small20){
            message=message.replace("{big}","65岁以上");
        }else if(between40_65>Big65&&between40_65>between20_40&&between40_65>small20){
            message=message.replace("{big}","40-65岁");
        }else if(between20_40>Big65&&between20_40>between40_65&&between20_40>small20){
            message=message.replace("{big}","20-40岁");
        }else if(small20>Big65&&small20>between40_65&&small20>between20_40){
            message=message.replace("{big}","20岁以下");
        }
//        DecimalFormat df   = new DecimalFormat("######0.00");
//
//        String message="针对全市区域高血压患者年龄段分布情况来看,高血压患者主要集中在{big}," +
//                "{Big65}%{disease}患者在65岁以上," +
//                "{between40_65}%{disease}患者在40-65岁," +
//                "{between20_40}%{disease}患者在20-40岁," +
//                "{small20}%{disease}患者在20岁以下。";
//
//        Double Big65=return1.getDouble("65岁以上");
//        Double between40_65=return1.getDouble("40-65岁");
//        Double between20_40=return1.getDouble("20-40岁");
//        Double small20=return1.getDouble("20岁以下");
//
//        message=message.replace("{Big65}",df.format(Big65*100));
//        message=message.replace("{between40_65}",df.format(between40_65*100));
//        message=message.replace("{between20_40}",df.format(between20_40*100));
//        message=message.replace("{small20}",df.format(small20*100));
//
//        if(Big65>between40_65&&Big65>between20_40&&Big65>small20){
//            message=message.replace("{big}","65岁以上");
//        }else if(between40_65>Big65&&between40_65>between20_40&&between40_65>small20){
//            message=message.replace("{big}","40-65岁");
//        }else if(between20_40>Big65&&between20_40>between40_65&&between20_40>small20){
//            message=message.replace("{big}","20-40岁");
//        }else if(small20>Big65&&small20>between40_65&&small20>between20_40){
//            message=message.replace("{big}","20岁以下");
//        }
        switch (value){
            case "高血压":{
                message=message.replace("{disease}","高血压");
                return message;
//                message=message.replace("{disease}","高血压");
                return "针对全市区域高血压患者年龄段分布情况来看,高血压患者主要集中在40-65岁。根据区域性别分布比例来看,女性高血压患病几率较高。";
            }
            case "糖尿病":{
                message=message.replace("{disease}","糖尿病");
                return message;
//                message=message.replace("{disease}","糖尿病");
                return "针对全市区域糖尿病患者年龄段分布情况来看,糖尿病患者主要集中在40-65岁。根据区域性别分布比例来看,女性糖尿病患病几率较高。";
            }
        }
        return "";

+ 2 - 1
patient-co/patient-co-statistics/src/main/resources/application.yml

@ -218,8 +218,9 @@ spring:
      password: 123456
  redis:
    host: 172.19.103.47 # Redis server host.
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
  followupMessage:
    cron : 0 5 0 * * ?

+ 9 - 9
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java

@ -46,9 +46,9 @@ public class HealthArtListener implements MessageListener {
    public void onMessage(Message message) {
        try {
            TextMessage textMessage = (TextMessage) message;
            JSONObject jo = JSONObject.fromObject(textMessage.getText());
            logger.info(jo.toString());
            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
//            logger.info(jo.toString());
            sendWxTemplateAndIM(healthEduArticlePatient);
            //返回服务器表示消息消费成功
            message.acknowledge();
        } catch (JMSException e) {
@ -57,15 +57,15 @@ public class HealthArtListener implements MessageListener {
    }
    //发送到IM和
    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients, Integer sendType) {
    //发送到IM和微信消息模板
    private void sendWxTemplateAndIM(HealthEduArticlePatient one) {
        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
        healthEduArticlePatients.stream().forEach(one -> {
//        healthEduArticlePatients.stream().forEach(one -> {
            Patient patient = patientService.findByCode(one.getPatient());
            try {
                //卫纪委发送不推IM
                if (1 == sendType) {
                if (1 == one.getSendType()) {
                    consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                    if (StringUtils.isNotBlank(one.getAttachedMessage())) {
                        //发送备注
@ -76,7 +76,7 @@ public class HealthArtListener implements MessageListener {
                org.json.JSONObject json = new org.json.JSONObject();
                json.put("first", patient.getName() + ",您好! " + one.getSendName() + "医生给您发来了一篇患教文章");
                json.put("toUser", patient.getCode());
                json.put("article", one.getId() + "");
                json.put("article", one.getArticleId() + "");
                json.put("title", one.getAttachedTitle());
                json.put("doctorName", one.getSendName());
                json.put("represented", patient.getCode());//被代理人
@ -111,6 +111,6 @@ public class HealthArtListener implements MessageListener {
            } catch (Exception e) {
                logger.error("patient:" + patient.getCode() + "," + e.getMessage());
            }
        });
//        });
    }
}

+ 18 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -98,6 +98,14 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("zy_execute_sick_settle_job reorder job job exist");
            }
            //处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
            if (!quartzHelper.isExistJob("prescription_pay_query_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prescription_pay_query_job");
                quartzHelper.addJob(PrescriptionPayQueryJob.class, trigger, "prescription_pay_query_job", new HashMap<String, Object>());
                logger.info("prescription_pay_query_job reorder job job success");
            } else {
                logger.info("prescription_pay_query_job reorder job job exist");
            }
            //居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
            if (!quartzHelper.isExistJob("finish_consult_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("finish_consult_job");
@ -107,6 +115,16 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("finish_consult_job exist");
            }
            //提醒有监测方案的居民上传数据,每29分钟执行一次
            if (!quartzHelper.isExistJob("doctor_feldsher_template_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("doctor_feldsher_template_job");
                quartzHelper.addJob(DoctorFeldsherTemplateJob.class, trigger, "doctor_feldsher_template_job", new HashMap<String, Object>());
                logger.info("doctor_feldsher_template_job reorder job job success");
            } else {
                logger.info("doctor_feldsher_template_job reorder job job exist");
            }
            // 启动redis 消息队列线程
            logger.info("redis message start");
            new Thread(redisThread).start();

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -29,7 +29,7 @@ public interface DevicePatientHealthIndexDao
    Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date);
    @Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate between ?3 and ?4 and a.del = '1' group by recordDate order by recordDate asc")
    Iterable<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
    List<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
    @Query("select a.value1 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value1 > 0 and a.del = '1' order by recordDate desc")
    Page<String> findValue1ByPatient(String user, int type, Date recordDate, Pageable pageRequest);

+ 255 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorFeldsherTemplateJob.java

@ -0,0 +1,255 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.patient.PatientSchemeListDao;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
 * 处理有监测方案的居民在一定时间范围内收到模板消息提醒
 * Created by Reece on 2017/8/29/029.
 */
@DisallowConcurrentExecution//解决执行频率和间隔时间的问题。到了执行时间点前一任务还在执行中,不会执行下一次任务,直至该次任务完成
public class DoctorFeldsherTemplateJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateJob.class);
    @Autowired
    private PatientSchemeListDao schemeListDao;
    @Autowired
    private DoctorFeldsherTemplateService feldsherTemplateService;
    @Autowired
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("DoctorFeldsherTemplateJob start ..........");
        try {
            //获取居民在监测方案的监测时间前30分钟未上传监测数据
            SimpleDateFormat formatHour = new SimpleDateFormat("HH:mm:ss");
            List<DoctorSchemeBloodSugger> patientCodeList = schemeListDao.findSuggerPatient();
            for (DoctorSchemeBloodSugger patientCodeLis : patientCodeList) {
                String schemecode = patientCodeLis.getCode();
                short beforeBreakfast = patientCodeLis.getBeforeBreakfast();
                Time beforeBreakfastTime = patientCodeLis.getBeforeBreakfastTime();
                short afterBreakfast = patientCodeLis.getAfterBreakfast();
                Time afterBreakfastTime = patientCodeLis.getAfterBreakfastTime();
                short beforeLunch = patientCodeLis.getBeforeLunch();
                Time beforeLunchTime = patientCodeLis.getBeforeLunchTime();
                short afterLunch = patientCodeLis.getAfterLunch();
                Time afterLunchTime = patientCodeLis.getAfterLunchTime();
                short beforeDinner = patientCodeLis.getBeforeDinner();
                Time beforeDinnerTime = patientCodeLis.getBeforeDinnerTime();
                short afterDinner = patientCodeLis.getAfterDinner();
                Time afterDinnerTime = patientCodeLis.getAfterDinnerTime();
                short beforeSleep = patientCodeLis.getBeforeSleep();
                Time beforeSleepTime = patientCodeLis.getBeforeSleepTime();
                String toDay = formatHour.format(new Date());
                long to = formatHour.parse(toDay).getTime();
                if (beforeBreakfast == 1) {
                    Time tempTime = Time.valueOf("00:00:00");
                    long tempTo = tempTime.getTime();
                    long from = beforeBreakfastTime.getTime();
                    int minutes = (int) ((from - tempTo) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,tempTime,beforeBreakfastTime,"早餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterBreakfast == 1) {
                    long from = afterBreakfastTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeBreakfastTime,afterBreakfastTime,"早餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (beforeLunch == 1) {
                    long from = beforeLunchTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterBreakfastTime,beforeLunchTime,"午餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterLunch == 1) {
                    long from = afterLunchTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeLunchTime,afterLunchTime,"午餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (beforeDinner == 1) {
                    long from = beforeDinnerTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterLunchTime,beforeDinnerTime,"晚餐前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterDinner == 1) {
                    long from = afterDinnerTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,beforeDinnerTime,afterDinnerTime,"晚餐后");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (beforeSleep == 1) {
                    long from = beforeSleepTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,1,schemecode,afterDinnerTime,beforeSleepTime,"睡前");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
            }
            List<DoctorSchemeBloodPressure> patientCodes = schemeListDao.findPressurePatient();
            for (DoctorSchemeBloodPressure patientCodeLis : patientCodes) {
                String schemecode = patientCodeLis.getCode();
                short earlyMorning = patientCodeLis.getEarlyMorning();
                Time earlyMorningTime = patientCodeLis.getEarlyMorningTime();
                short morning = patientCodeLis.getMorning();
                Time morningTime = patientCodeLis.getMorningTime();
                short noon = patientCodeLis.getNoon();
                Time noonTime = patientCodeLis.getNoonTime();
                short afterNoon = patientCodeLis.getAfterNoon();
                Time afterNoonTime = patientCodeLis.getAfterNoonTime();
                short night = patientCodeLis.getNight();
                Time nightTime = patientCodeLis.getNightTime();
//                比较现在时间和监测时间《=30
                String toDay = formatHour.format(new Date());
                long to = formatHour.parse(toDay).getTime();
                if (earlyMorning == 1) {
                    Time tempTime = Time.valueOf("00:00:00");
                    long tempTo = tempTime.getTime();
                    long from = earlyMorningTime.getTime();
                    int minutes = (int) ((from - tempTo) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,tempTime,earlyMorningTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (morning == 1) {
                    long from = morningTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,earlyMorningTime,morningTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (noon == 1) {
                    long from = noonTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,morningTime,noonTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (afterNoon == 1) {
                    long from = afterNoonTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,noonTime,afterNoonTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
                if (night == 1) {
                    long from = nightTime.getTime();
                    int minutes = (int) ((from - to) / (1000 * 60));
                    try {
                        sendPatientHealth(minutes,2,schemecode,afterNoonTime,nightTime,"");
                    } catch (Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
            }
            logger.info("DoctorFeldsherTemplateJob end ..........");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("DoctorFeldsherTemplateJob error ..........,message:" + e.getMessage());
        }
    }
    /**
     *
     * @param minutes 监测时间差值
     * @param type 监测类型 2为血压,1为血糖
     * @param schemecode 关联监测方案
     * @param beginTime 起始时间点
     * @param endTime 截止时间点
     * @param comment 血糖时间段名称
     * @throws Exception
     */
    private void sendPatientHealth(int minutes, int type, String schemecode, Time beginTime, Time endTime,String comment) throws Exception {
        SimpleDateFormat formatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat formatDay = new SimpleDateFormat("yyyy-MM-dd ");
        Date today = new Date();
        if (minutes <= 30 && minutes > 0) {
            PatientSchemeList patient = schemeListDao.findPatientBySchemecode(schemecode, (short) 1);
            String patientCode = patient.getPatientcode();
            String day = formatDay.format(today);
            Date begin = formatTime.parse(day + beginTime);
            Date end = formatTime.parse(day + endTime);
            List<DevicePatientHealthIndex> healthIndices = patientHealthIndexDao.findByPatient(patientCode, type, begin, end);
            if (healthIndices==null || healthIndices.size()==0) {
                try {
                    //为居民发送监测代办事项提醒消息
                    feldsherTemplateService.sendChangeTemplate(type, patientCode, comment);
                } catch (Exception e) {
                    logger.info("DoctorFeldsherTemplateJob error ..........continue this JOB,CODE:" + patientCode + ",message:" + e.getMessage());
                }
            }
        }
    }
}

+ 57 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayQueryJob.java

@ -0,0 +1,57 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
 * 处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
 * Created by Reece on 2017/8/29/029.
 */
public class PrescriptionPayQueryJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(PrescriptionPayQueryJob.class);
    @Autowired
    private PrescriptionPayDao prescriptionPayDao;
    @Autowired
    private PatientPrescriptionPayService payService;
    @Autowired
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("PrescriptionPayQueryJob start ..........");
        try {
            String accesstoken =  weiXinAccessTokenUtils.getAccessToken();
            //获取支付完成,院内结算失败的 处方CODE 集合
            List<String> prescriptionCodeList = prescriptionPayDao.findTodayUnpay();
            if (!prescriptionCodeList.isEmpty()) {
                for (String code : prescriptionCodeList) {
                    try {
                        payService.chargeQuery(code,accesstoken);
                    } catch (Exception e) {
                        logger.info("PrescriptionPayQueryJob error ..........continue this JOB,CODE:" + code + ",message:" + e.getMessage());
                        continue;
                    }
                }
            }
            logger.info("PrescriptionPayQueryJob end ..........");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("PrescriptionPayQueryJob error ..........,message:" + e.getMessage());
        }
    }
}

+ 27 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientSchemeListDao.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientSchemeListDao extends PagingAndSortingRepository<PatientSchemeList, Long>, JpaSpecificationExecutor<PatientSchemeList> {
    //联合wlyy_patient_scheme_list和wlyy_doctor_scheme_blood_pressure查询有血糖监测方案且在监测时间前十分钟未上传监测数据
    @Query(value = " select s from PatientSchemeList p,DoctorSchemeBloodSugger s where p.schemecode=s.code and p.type = 1 and s.alertTag = 1 ")
    List<DoctorSchemeBloodSugger> findSuggerPatient();
    //联合wlyy_patient_scheme_list和wlyy_doctor_scheme_blood_pressure查询有血压监测方案且在监测时间前十分钟未上传监测数据
    @Query(" select s from PatientSchemeList p,DoctorSchemeBloodPressure s where p.schemecode=s.code and p.type=0 and s.alertTag = 1 ")
    List<DoctorSchemeBloodPressure> findPressurePatient();
    //根据schemecode查询患者监测方案
    @Query(" select p from PatientSchemeList p where p.schemecode = ?1 and p.type = ?2 ")
    PatientSchemeList findPatientBySchemecode(String schemecode,short type);
}

+ 10 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionPayDao.java

@ -5,10 +5,20 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionPayDao extends PagingAndSortingRepository<PrescriptionPay, Long>, JpaSpecificationExecutor<PrescriptionPay> {
    @Query("from PrescriptionPay p where p.prescriptionCode=?1 ")
    PrescriptionPay findByPrescriptionPay(String prescriptionCode);
    //查询支付记录
    @Query("from PrescriptionPay p where p.code=?1 ")
    PrescriptionPay findByCode(String code);
    //   查询当天支付,页面回调及异步回调均失败的支付 tradeStatus为空
    @Query(value = "SELECT t.`code` FROM wlyy_prescription_pay t WHERE t.trade_status is null AND t.create_time >= date(now()) AND t.create_time < DATE_ADD(date(now()), INTERVAL 1 DAY)", nativeQuery = true)
    List<String> findTodayUnpay();
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/ylz/PayConfiguraDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.ylz;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/9/9.
 */
public interface PayConfiguraDao extends PagingAndSortingRepository<PayConfigura, Long>, JpaSpecificationExecutor<PayConfigura> {
    //查询有效支付相关配置(只有一条有效记录)
    @Query("select t from PayConfigura t where t.del = 1 ")
    PayConfigura findWorkConfigura();
}

+ 249 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -0,0 +1,249 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.SystemConf;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by Reece on 2017/7/28/028.
 * 患者支付
 */
@Service
public class PatientPrescriptionPayService extends BaseService {
    private Logger logger=LoggerFactory.getLogger(PatientPrescriptionPayService.class);
    //公共配置文件
    Properties systemConf = SystemConf.getInstance().getSystemProperties();
    //    各环境对应配置
    @Value("${server.server_url}")
    private String serverUrl;
    @Value("${wechat.accId}")
    private String accId;
    //    Java配置文件 后续删除
    private String signType = "MD5";
    private String encryptType = "AES";
    //    引入实例
    @Autowired
    private PayConfiguraDao configuraDao;
    @Autowired
    private PrescriptionPayDao payDao;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        int flag = 0;
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
        PrescriptionPay charge = payDao.findByCode(code);
        String prescriptionCode = charge.getPrescriptionCode();
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        HospitalMapping hospitalMapping = mappingDao.findByCode(prescription.getHospital());
//          ***************************  测通流程 ***************************************
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
        try {
            RequestParams requestParams = new RequestParams();
//            requestParams.setVersion();
//            requestParams.setSign();
//            requestParams.setEncryptData();
//            requestParams.setAppId(appId);
            requestParams.setAppId(hospitalMapping.getAppId());
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTransType(config.getChargeQueryType());
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outChargeNo", code);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
//              ***************************  测通流程 ***************************************
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                result = JSON.toJSONString(res.getParam());
//                新增保存数据
                JSONObject request = JSON.parseObject(result);
//                String tradeStatus = request.getString("tradeStatus");//交易状态
                String chargeStatus = request.getString("chargeStatus");//交易状态
                String chargeNo = request.getString("chargeNo");//支付平台流水号
                String chargeTime = request.getString("chargeTime");//支付平台交易成功时间
                String outChargeNo = request.getString("outChargeNo");//接入应用业务流水号
                String outChargeTime = request.getString("outChargeTime");//接入应用时间
                String medOrgNo = request.getString("medOrgNo");//医疗机构编号
                String medOrgName = request.getString("medOrgName");//医疗机构名称
                String billNo = request.getString("billNo");//待结算费用单据号
                String cardNo = request.getString("cardNo");//医保卡号
                String totalAmount = request.getString("totalAmount");//交易总金额
                String insuranceAmount = request.getString("insuranceAmount");//医保支付金额
                String selfPayAmount = request.getString("selfPayAmount");//自付金额
                String userId = request.getString("userId");//用户openID
                String userName = request.getString("userName");//用户名字
                String idNo = request.getString("idNo");//证件号码
                String idType = request.getString("idType");//证件类型
//                String appId = request.getString("appId");
//                String channel = request.getString("channel");//支付方式
//                String sign = request.getString("sign");
//                String signType = request.getString("signType");
//                String timestamp = request.getString("timestamp");
                JSONObject responseContents = request.getJSONObject("responseContent");//医保结构体
                PrescriptionPay prescriptionPay = payDao.findByCode(outChargeNo);
                if (responseContents != null) {
                    String miSettleNo = responseContents.getString("miSettleNo");//医保收费单据号 (医保签约号)
                    String miRegisterNo = responseContents.getString("miRegisterNo");//医保挂号
                    String miCollectDate = responseContents.getString("miCollectDate");//收费日期
                    String miCollectTime = responseContents.getString("miCollectTime");//收费时间
                    String miCollectorName = responseContents.getString("miCollectorName");//收费人姓名
                    String miTotalFee = responseContents.getString("miTotalFee");//本次报销总额
                    String selfPay = responseContents.getString("selfPay");//个人现金支付
                    String accountPay = responseContents.getString("accountPay");//个人账户支付
                    String heathPay = responseContents.getString("heathPay");//健康账户支付
                    String cadresPay = responseContents.getString("cadresPay");//公务员补助
                    String fundPay = responseContents.getString("fundPay");//基金支付
                    String healthCarePay = responseContents.getString("healthCarePay");//保健基金支付
                    String commercePay = responseContents.getString("commercePay");//商业保险支付
                    String familyPay = responseContents.getString("familyPay");//共济账户支付
                    String civilPay = responseContents.getString("civilPay");//民政补助金额
                    String civilZone = responseContents.getString("civilZone");//民政行政区号
                    String bdrugPay = responseContents.getString("bdrugPay");//乙类支付金额
                    String unlessAmount = responseContents.getString("unlessAmount");//非医保费用
                    String exceedAmount = responseContents.getString("exceedAmount");//超封顶线金额
                    String accountBalance = responseContents.getString("accountBalance");//个人账户余额
                    String healthBalance = responseContents.getString("healthBalance");//健康账户余额
                    prescriptionPay.setMiSettleNo(miSettleNo);//医保收费单据号
                    prescriptionPay.setMiRegisterNo(miRegisterNo);//医保挂号
                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMdd");
                    prescriptionPay.setMiCollectDate(formatDate.parse(miCollectDate));//收费日期
                    SimpleDateFormat formatTime = new SimpleDateFormat("HHmm");
                    prescriptionPay.setMiCollectTime(formatTime.parse(miCollectTime));//收费时间
                    prescriptionPay.setMiCollectorName(miCollectorName);//收费人姓名
                    prescriptionPay.setMiTotalFee(Integer.parseInt(miTotalFee));//本次报销总额
                    prescriptionPay.setSelfPay(Integer.parseInt(selfPay));//个人现金支付
                    prescriptionPay.setAccountPay(Integer.parseInt(accountPay));//个人账户支付
                    prescriptionPay.setHeathPay(Integer.parseInt(heathPay));//健康账户支付
                    prescriptionPay.setCadresPay(Integer.parseInt(cadresPay));//公务员补助
                    prescriptionPay.setFundPay(Integer.parseInt(fundPay));//基金支付
                    prescriptionPay.setHealthCarePay(Integer.parseInt(healthCarePay));//保健基金支付
                    prescriptionPay.setCommercePay(Integer.parseInt(commercePay));//商业保险支付
                    prescriptionPay.setFamilyPay(Integer.parseInt(familyPay));//共济账户支付
                    prescriptionPay.setCivilPay(Integer.parseInt(civilPay));//民政补助金额
                    prescriptionPay.setCivilZone(civilZone);//民政行政区号
                    prescriptionPay.setBdrugPay(Integer.parseInt(bdrugPay));//乙类支付金额
                    prescriptionPay.setUnlessAmount(Integer.parseInt(unlessAmount));//非医保费用
                    prescriptionPay.setExceedAmount(Integer.parseInt(exceedAmount));//超封顶线金额
                    prescriptionPay.setAccountBalance(Integer.parseInt(accountBalance));//个人账户余额
                    prescriptionPay.setHealthBalance(Integer.parseInt(healthBalance));//健康账户余额
                }
                if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
                    prescriptionPay.setTradeStatus("1");//交易状态 成功1 失败0
                }else {
                    prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                }
                prescriptionPay.setChargeNo(chargeNo);//支付流水号
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
                prescriptionPay.setChargeTime(formatDate.parse(chargeTime));//支付平台交易成功时间
                prescriptionPay.setOutChargeTime(formatDate.parse(outChargeTime));//接入应用内业务时间
                prescriptionPay.setMedOrgNo(medOrgNo);//医疗机构编号
                prescriptionPay.setMedOrgName(medOrgName);//医疗机构名称
                prescriptionPay.setBillNo(billNo);//待结算费用单据号
                prescriptionPay.setCardNo(cardNo);//医保卡号
                prescriptionPay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
                prescriptionPay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
                prescriptionPay.setSelfPayAmount(Integer.parseInt(selfPayAmount));//自付金额
                prescriptionPay.setOpenid(userId);
                prescriptionPay.setUserName(userName);
                prescriptionPay.setIdType(idType);//证件类型
                prescriptionPay.setIdNo(idNo);//证件号码
                //        保存数据库更改记录
                payDao.save(prescriptionPay);
                logger.info("请求成功,返回参数: " + result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
        if (!isSuccess) {
            throw new Exception(error);
        }
        return result;
    }
}

+ 122 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -0,0 +1,122 @@
package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 医生助手相关模板消息
 * <p>
 * Created by Reece on 2017/9/7/007.
 */
@Service
@Transactional
public class DoctorFeldsherTemplateService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateService.class);
    /**
     * 医生为居民设置监测方案后实时为居民推送信息变更通知消息提醒
     *
     * @param type    监测类型 2为血压,1为血糖
     * @param patient 居民code
     * @param comment 血糖时间段名称
     * @throws Exception
     */
    public void sendChangeTemplate(int type, String patient, String comment) throws Exception {
        Patient people = patientDao.findByCode(patient);
        String openId = people.getOpenid();
        String name = people.getName();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONArray jsonArray = null;
        JSONObject sendJson = new JSONObject();
        if (type == 1) {
            String url = "jkjl/html/health-index-add-bloodsugar.html?openid=" + openId + "&toUser=" + patient + "&toName=" +name+"&represented="+patient;
            String first = name + "您好,请按照您的血糖监测方案测量" + comment + "血糖数据。";
            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1", "血糖测量");
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, openId, name, sendJson);
            //发送代理人
            jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    int start = url.indexOf("&toUser=");
                    int end = url.indexOf("&", start + 1);
                    String touser = url.substring(start, end);
                    url = url.replace(touser, "&toUser=" + member.getCode());
                    int representedStart = url.indexOf("&represented=");
                    int representedEnd = url.length();
                    String represented = url.substring(representedStart, representedEnd);
                    url = url.replace(represented, "&represented=" + member.getCode());
                    //name患者姓名
                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                    sendJson.put("url", url);
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), name, sendJson);
                }
            }
            logger.info("sendJson: " + sendJson);
        }
        if (type == 2) {
            String url = "jkjl/html/health-index-add-bloodpressure.html?openid=" + openId + "&toUser=" + patient + "&toName=" +name+"&represented="+patient;
            String first = name + "您好,请按照您的血压监测方案测量血压数据。";
            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1", "血压测量");
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, openId, name, sendJson);
            //发送代理人
            jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    int start = url.indexOf("&toUser=");
                    int end = url.indexOf("&", start + 1);
                    String touser = url.substring(start, end);
                    url = url.replace(touser, "&toUser=" + member.getCode());
                    int representedStart = url.indexOf("&represented=");
                    int representedEnd = url.length();
                    String represented = url.substring(representedStart, representedEnd);
                    url = url.replace(represented, "&represented=" + member.getCode());
                    //name患者姓名
                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                    sendJson.put("url", url);
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), name, sendJson);
                }
            }
            logger.info("sendJson: " + sendJson);
        }
    }
}

+ 39 - 3
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -407,9 +407,9 @@ public class JobController extends BaseController {
    }
    /**
     *遍历长处方支付成功但是院内结算失败的记录,重新执行院内结算 --
     *@author huangwenjie
     *@date 2017/8/18 14:16
     * 居民24小时未回复咨询自动结束
     * @author ysj
     * @date 2017/9/11 14:16
     */
    @RequestMapping(value = "/executeFinishConsultJob", method = RequestMethod.POST)
    @ApiOperation("居民24小时未回复咨询自动结束")
@ -426,6 +426,7 @@ public class JobController extends BaseController {
    /**
     * 立即启动支付超时过期
     *
     * @Author Linyx
     * @params method
     * @Date 2017/8/14 11:07
@ -443,5 +444,40 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /**
     * 遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存
     *
     * @author wujunjie
     * @date 2017/8/30 14:16
     */
    @RequestMapping(value = "/prescriptionPayQueryJob", method = RequestMethod.POST)
    @ApiOperation("遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存")
    public String PrescriptionPayQueryJob() {
        try {
            quartzHelper.startNow(PrescriptionPayQueryJob.class, "PRESCRIPTION-PAY_QUERY", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    //******************************长处方 end********************************
    /**
     * 居民监测方案提醒通知
     *
     * @author wujunjie
     * @date 2017/9/12 14:16
     */
    @RequestMapping(value = "/doctorFeldsherTemplateJob", method = RequestMethod.POST)
    @ApiOperation("提醒有监测方案的居民上传数据")
    public String DoctorFeldsherTemplateJob() {
        try {
            quartzHelper.startNow(DoctorFeldsherTemplateJob.class, "DOCTOR_FELDSHER_TEMPLATE", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 4 - 4
patient-co/patient-co-wlyy-job/src/main/resources/application-dev.yml

@ -15,13 +15,13 @@ spring:
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
    password:
channel:
  redis:
    host: 59.61.92.90  # Redis server host.
    port: 9054 # Redis server port.
    password: jkzlehr
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
    password: jkzl_ehr
server:
  server_url: http://weixin.xmtyw.cn/wlyy-dev/

+ 5 - 0
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -89,10 +89,15 @@ zy_dict_job=0 0 1 * * ?
#遍历支付成功,院内结算失败的的记录,重新结算,10分钟跑一次
zy_execute_sick_settle_job=0 0/10 * * * ?
#处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
prescription_pay_query_job=0 0/3 * * * ?
#居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
finish_consult_job=* 59 * * * ?
#提醒有监测方案的居民上传数据,每29分钟执行一次
doctor_feldsher_template_job=0 0/29 * * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html

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

@ -137,7 +137,7 @@ public class DoctorInterceptor extends BaseInterceptor {
                }
            }
            //  2、医生端app,3、微信公众号wechat,4、医生端pc,或者 PC端取药系统  或者对外系统
            if (token == null || (token.getPlatform() != 2 && token.getPlatform() != 4)) {
            if (token == null || (token.getPlatform() != 2 && token.getPlatform() != 4&&token.getPlatform()!=5)) {
                // 未登录
                response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes("UTF-8"));
                flag = false;

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/address/CountryDao.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.repository.address;
import com.yihu.wlyy.entity.address.Country;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -9,7 +10,7 @@ import java.util.List;
 * Created by Trick on 2017/7/20.
 */
public interface CountryDao extends PagingAndSortingRepository<Country, Long> {
    @Query("from Country c where c.street=?1 AND (c.jwCode IS NOT NULL OR c.jwCode <> '')")
    List<Country> findByStreet(String street);
    Country findByCode(String code);

+ 24 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java

@ -0,0 +1,24 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 血压监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/13 20:24
 */
public interface DoctoreSchemeBloodPressureDao extends
        PagingAndSortingRepository<DoctorSchemeBloodPressure, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodPressure> {
    @Query(" from DoctorSchemeBloodPressure p where p.doctorcode=?1 ORDER BY createTime DESC ")
    List<DoctorSchemeBloodPressure> getListByDoctorcode(String doctorCode);
    @Query(" from DoctorSchemeBloodPressure p where p.code=?1")
    DoctorSchemeBloodPressure findByCode(String code);
}

+ 15 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodSuggerDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 血糖监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/14 00:04
 */
public interface DoctoreSchemeBloodSuggerDao extends
        PagingAndSortingRepository<DoctorSchemeBloodSugger, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodSugger> {
}

+ 29 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctroSchemeBloodSuggerDao.java

@ -0,0 +1,29 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;
/**
 * 医生血糖监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/13 20:08
 */
@Entity
@Table(name = "wlyy_doctor_scheme_blood_sugger")
public interface DoctroSchemeBloodSuggerDao extends
        PagingAndSortingRepository<DoctorSchemeBloodSugger, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodSugger> {
    @Query(" from DoctorSchemeBloodSugger p where p.doctorcode=?1 ORDER BY createTime DESC ")
    List<DoctorSchemeBloodSugger> getListByDoctorcode(String doctorcode);
    @Query(" from DoctorSchemeBloodSugger p where p.code=?1")
    DoctorSchemeBloodSugger findByCode(String code);
}

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientAimSportsDao.java

@ -0,0 +1,23 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 居民-运动目标
 * @author huangwenjie
 * @date 2017/9/12 16:07
 */
public interface PatientAimSportsDao extends
        PagingAndSortingRepository<PatientAimSports, Long>,
        JpaSpecificationExecutor<PatientAimSports> {
    @Query("from PatientAimSports p where p.code=?1")
    PatientAimSports findByCode(String code);
    @Query("from PatientAimSports p where p.patientcode =?1")
    PatientAimSports getPatientAimSportsByPatientCode(String patientCode);
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/scheme/PatientSchemeListDao.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.repository.patient.scheme;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 监测方案关联关系表
 * @author huangwenjie
 * @date 2017/9/13 23:21
 */
public interface PatientSchemeListDao extends
        PagingAndSortingRepository<PatientSchemeList, Long>,
        JpaSpecificationExecutor<PatientSchemeList> {
    @Query("delete from PatientSchemeList where patientcode=?1 and type=?2 and schemecode=?3")
    void delByPatientCodeAndSchemeCode(String patientcode, int i, String code);
}

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java

@ -15,6 +15,7 @@ public interface PrescriptionExpressageDao extends PagingAndSortingRepository<Pr
    @Query("from PrescriptionExpressage p where p.mailno=?1")
    PrescriptionExpressage findByPrescriptionExpressMailno(String mailno);
    @Query(" from PrescriptionExpressage p where p.prescriptionCode=?1 and p.del=1")
    PrescriptionExpressage findByPrescriptionCode(String prescriptionCode);
}

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/ylz/PayConfiguraDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.ylz;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/9/9.
 */
public interface PayConfiguraDao extends PagingAndSortingRepository<PayConfigura, Long>, JpaSpecificationExecutor<PayConfigura> {
    //查询有效支付相关配置(只有一条有效记录)
    @Query("select t from PayConfigura t where t.del = 1 ")
    PayConfigura findWorkConfigura();
}

+ 56 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -31,10 +31,13 @@ import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -87,7 +90,10 @@ public class PatientInfoService extends BaseService {
    PatientService patientService;
    @Autowired
    SystemDictDao systemDictDao;
    @Autowired
    JwArchivesService jwArchivesService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    /**
     * 患者更换手机号
@ -328,4 +334,53 @@ public class PatientInfoService extends BaseService {
        return 1;
    }
    public int createProfile(String doctorCode ,String patient,String brithday,String jwCountryCode,String nation,String blood,String marry,String adress)throws Exception{
        Patient p = patientDao.findByCode(patient);
        JSONObject json = new JSONObject();
        json.put("ARCHIVE_TIME", DateUtil.getStringDateShort());//建档时间
        json.put("ARCHIVE_STATUS","3");//档案状态【1.未管理 2.死亡 3.正常 4.高危】
        json.put("SICK_NAME",p.getName());//姓名
        json.put("SICK_SEX",p.getSex());//性别【1.男 2.女 9 未知】
        json.put("BIRTHDAY",brithday);//出生日期
        json.put("ZONE_CODE",jwCountryCode);//所属社区【ZONE_DICT】
        json.put("IDENTITY_TYPE","1");//证件类型【IDENTITY_TYPE_DICT】
        json.put("IDENTITY_CARD_NO",p.getIdcard());//身份证号
        json.put("HOME_PHONE",p.getMobile());//本人电话
        json.put("HOME_ADDRESS",adress);//现住址
        json.put("ORG_ID","0");//新增默认传0
        json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
        json.put("NATIONAL",nation);//民族【NATION_DICT】
        json.put("ORIGO","3502030502");//户口所在地【ZONE_DICT】
        json.put("BLOOD",blood);//血型【1.A型 2.3.O型4.AB型 5.不详】
        json.put("BLOOD_RH","1");//RH阴性【1.否 2.是 3.不详】
        json.put("MARRIAGE",marry);//婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
        String doctor = doctorCode;
        String response = jwArchivesService.saveSickArchiveRecord(json.toString(),doctor);
        return 1;
    }
    public  List<Map<String,Object>> getNationDict(){
        String sql = "SELECT t.NATION_CODE,t.NATION_NAME FROM zy_nation_dict t ";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String,Object>> getMarryDict(){
        return getDictByName("MARRY_STATE");
    }
    public List<Map<String,Object>> getBloodDict(){
        return getDictByName("BLOOD_TYPE");
    }
    public List<Map<String,Object>> getDictByName(String name){
        String sql = "SELECT t.code,t.`value` FROM system_dict t WHERE t.dict_name=?";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql,new Object[]{name});
        return rs;
    }
}

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

@ -6,14 +6,12 @@ import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientHealthStandardDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.task.HealthIndexUploadTask;
@ -40,6 +38,7 @@ import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@ -59,22 +58,20 @@ public class PatientHealthIndexService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
@ -645,7 +642,7 @@ public class PatientHealthIndexService extends BaseService {
     * 新增患者指标
     * 【血糖】{"time":"2016-09-09 17:00:00","gi":"血糖值(mmol/L)"}
     * 【血压】{"time":"2016-09-09 17:00:00","sys":"收缩压(mmHg)","dia":"舒张压(mmHg)","pul":"脉搏(次/分)","ano":"有无心率不齐0否 1是","user":"身份标识"}
     * 【体重】{"time":"2016-09-09 17:00:00","weight":"体重值(kg)"}
     * 【体重/身高】{"time":"2016-09-09 17:00:00","weight":"体重值(kg)","height":"身高(cm)"}
     * 【腰围】{"time":"2016-09-09 17:00:00","waistline":"腰围值(cm)"}
     *
     * @return
@ -724,7 +721,36 @@ public class PatientHealthIndexService extends BaseService {
                }
                case "3": {
                    obj.setType(3);
                    obj.setValue1(map.get("weight")); //体重
                    String weight = map.get("weight");
                    String height = map.get("height");
                    obj.setValue1(weight); //体重
                    obj.setValue2(height); //身高
                    PatientAimSports patientAimSports = new PatientAimSports();
                    patientAimSports = patientAimSportsDao.getPatientAimSportsByPatientCode(patientCode);
                    //如果该患者没有设置运动目标,则获取预置数据
                    if(patientAimSports == null || StringUtils.isBlank(patientAimSports.getCode())){
                        patientAimSports = patientAimSportsDao.findByCode("default");
                    }
                    double bmi = CommonUtil.getBMIByWeightAndHeight(map.get("weight"),map.get("height"));
                    DecimalFormat df1 = new DecimalFormat("###.00");
                    obj.setValue3(df1.format(bmi));
                    if(patientAimSports != null && StringUtils.isNoneEmpty(patientAimSports.getCode())){
                        //设置BMI值
                        if(bmi < Double.parseDouble(patientAimSports.getBmiMin())){
                            obj.setValue4("1");
                        }else if(bmi > Double.parseDouble(patientAimSports.getBmiMax())){
                            obj.setValue4("-1");
                        }else{
                            obj.setValue4("0");
                        }
                    }
                    break;
                }
                case "4": {

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

@ -240,9 +240,11 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param labelType 标签类型
     * @param page      第几页
     * @param pagesize  页大小
     * @param isSlowDisease 是否是慢病管理
     * @param diseaseCondition
     * @return
     */
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize) throws Exception {
    public JSONArray getPatientByLabel(String doctor, String labelCode, String labelType, Long teamCode, int page, int pagesize, boolean isSlowDisease, String diseaseCondition) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        if (doc == null) {
@ -251,6 +253,8 @@ public class SignPatientLabelInfoService extends BaseService {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
@ -307,10 +311,16 @@ public class SignPatientLabelInfoService extends BaseService {
                    " ) f " +
                    "WHERE " +
                    " f. CODE = s.sign_code " +
                    " AND s.server_type ='"+labelCode+"' " +
                    " ORDER BY " +
                    " AND s.server_type ='"+labelCode+"' ";
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.diseaseCondition = ?";
                args = new Object[]{doctor, doctor, teamCode,diseaseCondition};
            }else{
                args = new Object[]{doctor, doctor, teamCode};
            }
            sql = sql + " ORDER BY " +
                    " f.ptOpenid DESC";
            args = new Object[]{doctor, doctor, teamCode};
        } else {
            if (labelCode.equals("0")) {
                sql = "SELECT " +
@ -349,6 +359,12 @@ public class SignPatientLabelInfoService extends BaseService {
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(isSlowDisease){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
@ -454,6 +470,20 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -480,7 +510,24 @@ public class SignPatientLabelInfoService extends BaseService {
                public int compare(JSONObject o1, JSONObject o2) {
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = openid1.compareTo(openid2);
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(isSlowDisease){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {
@ -3511,13 +3558,16 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param teamCode
     * @param page
     * @param pagesize
     * @param sortByStandardStatus 是否根据预警状态排序,如果true, 需要附带查询患者设备绑定情况
     * @param diseaseCondition
     * @return
     * @throws Exception
     */
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize) throws Exception {
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize, boolean sortByStandardStatus, String diseaseCondition) throws Exception {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
@ -3566,14 +3616,21 @@ public class SignPatientLabelInfoService extends BaseService {
                    "  WHERE " +
                    "  p. CODE = t1.patient " +
                    "  AND t1. STATUS > 0 " +
                    "  AND t1.admin_team_code = ?" +
                    "  AND t1.admin_team_code = ?";
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.diseaseCondition = ?";
                args = new Object[]{teamCode,diseaseCondition};
            }else{
                args = new Object[]{teamCode};
            }
            sql = sql +
                    " ) f " +
                    "WHERE " +
                    " f. CODE = s.sign_code " +
                    " AND s.server_type ='"+labelCode+"' " +
                    " ORDER BY " +
                    " f.ptOpenid DESC";
                args = new Object[]{teamCode};
        }else {
            if ("0".equals(labelCode)) {
                sql = "SELECT " +
@ -3621,6 +3678,13 @@ public class SignPatientLabelInfoService extends BaseService {
        sql = sql + " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        if(sortByStandardStatus){
            String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
            patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
@ -3629,49 +3693,49 @@ public class SignPatientLabelInfoService extends BaseService {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
                }
//                if (result.containsKey(p.getCode())) {
//                    JSONObject jsonP = result.get(p.getCode());
//
//                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
//                        jsonP.put("signType", 3);
//                    }
//                    if (String.valueOf(sign.get("type")).equals("2")) {
//                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
//                        // 缴费情况
//                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
//                        // 缴费时间
//                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
//                        // 缴费类型
//                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
//                            boolean epTime = false;
//                            try {
//                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
//                            } catch (Exception e) {
//                                e.printStackTrace();
//                            }
//
//                            if (!epTime) {
//                                jsonP.put("expensesRemindStatus", 0);
//                            } else {
//                                jsonP.put("expensesRemindStatus", 1);
//                            }
//                        }
//                        boolean epTime = false;
//                        try {
//                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
//                        } catch (Exception e) {
//                            e.printStackTrace();
//                        }
//                        if (!epTime) {
//                            jsonP.put("wechatFocusRemind", 0);
//                        } else {
//                            jsonP.put("wechatFocusRemind", 1);
//                        }
//                    }
//
//                    continue;
//                }
                //List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
@ -3727,6 +3791,21 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -3753,7 +3832,25 @@ public class SignPatientLabelInfoService extends BaseService {
                public int compare(JSONObject o1, JSONObject o2) {
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = openid1.compareTo(openid2);
                    int re = 0;
                    //是否根据预警字段优先排序
                    if(sortByStandardStatus){
                        int standardStatus1 = o1.has("standardStatus")?o1.getInt("standardStatus"):0;
                        int standardStatus2 = o2.has("standardStatus")?o2.getInt("standardStatus"):0;
                        if(standardStatus1 == standardStatus2){
                            re = openid1.compareTo(openid2);
                        }else{
                            re = standardStatus1 - standardStatus1;
                        }
                    }else{
                        re = openid1.compareTo(openid2);
                    }
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {
@ -3910,4 +4007,445 @@ public class SignPatientLabelInfoService extends BaseService {
        }
    }
    /**
     * 慢病管理-根据患者姓名或标签名称查询
     *
     * @param doctor
     * @param filter
     * @param diseaseCondition
     * @return
     * @throws Exception
     */
    public JSONArray searchSlowDiseasePatientByNameOrLabel(String doctor, String filter,
                                                           String labelCode, String labelType, long teamCode,
                                                           String exLabelCode,
                                                           String exLabelType,
                                                           int page, int pagesize, String diseaseCondition) throws Exception {
        Doctor doc = doctorDao.findByCode(doctor);
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        if (doc == null) {
            throw new Exception("doctor info can not find");
        }
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        page = page * pagesize;
        Object[] args = null;
        String sql = "";
        //String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
//        String reg = "^(\\d+)([0-9]|X|x)$";
//        匹配数字字符串
        String reg = "[0-9]{1,}";
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(filter);
        sql = "select " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_sign_patient_label_info t2 ON t1.patient = t2.patient " +
                " JOIN wlyy_patiend t3 ON t1.patient = t3.code " +
                (teamCode > 0 ? " join (select * from wlyy_sign_patient_label where label_type != '4' or team_code = " + teamCode + " or (label_type = '4' and (label_code in (1,2)))) lb on t2.label = lb.label_code and t2.label_type = lb.label_type " : "") +
                " WHERE " +
                "    (t1.doctor = ? or t1.doctor_health = ?) " +
                "    AND t1.status > 0 " +
                "    AND t2.status = 1) " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : " AND (t2.label = 4 or t2.label = 5 )") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "")+
                (StringUtils.isNotEmpty(diseaseCondition) ? " AND t3.diseaseCondition = ? " : "");
        if (matcher.find()) {
            sql = sql + "  AND (t1.idcard like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%"};
            }
        } else {
            sql = sql + "  AND (t1.name like ? or t2.label_name like ?) ";
            if (StringUtils.isNotEmpty(labelCode)) {
                args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
                args = new Object[]{doctor, doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
            } else {
                args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
            }
        }
        if(StringUtils.isNotEmpty(diseaseCondition)){
            Object[] argsnew = new Object[args.length+1];
            for (int i = 0; i < argsnew.length; i++) {
                if(i == (argsnew.length-1)){
                    argsnew[i] = diseaseCondition;
                }else{
                    argsnew[i] = args[i];
                }
            }
            sql = sql + " order by t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            signList = jdbcTemplate.queryForList(sql, argsnew);
        }else{
            sql = sql + " order by t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            signList = jdbcTemplate.queryForList(sql, args);
        }
        String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
        patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
                }
                if (StringUtils.isNotEmpty(exLabelCode)) {
                    SignPatientLabelInfo labelInfoEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(p.getCode(), exLabelCode, exLabelType, 1);
                    if (labelInfoEx != null) {
                        continue;
                    }
                } else if (StringUtils.isNotEmpty(exLabelType)) {
                    List<SignPatientLabelInfo> labelExs = labelInfoDao.findByPatientAndLabelTypeAndStatus(p.getCode(), exLabelType, 1);
                    if (labelExs != null && labelExs.size() > 0) {
                        continue;
                    }
                }
                List<SignPatientLabelInfo> labels = null;
                if (teamCode > 0) {
                    labels = labelInfoDao.findByPatientAndStatusByTeam(sign.get("patient").toString(), 1, teamCode);
                } else {
                    labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                }
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                if("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }
        }
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * "慢病管理-查询所有团队下患者
     *
     * @param filter 搜索关键字
     * @param diseaseCondition
     * @return
     */
    public JSONArray searchSlowDiseaseTeamsPatients(String filter, long teamCode, int page, int pagesize, String diseaseCondition) throws Exception {
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String,Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        page = page * pagesize;
        //String reg = "(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
        String reg = "^(\\d+)([0-9]|X|x)$";
        Pattern pattern = Pattern.compile(reg);
        Matcher matcher = pattern.matcher(filter);
        boolean isIdcard = matcher.find();
        Object[] args = new Object[]{teamCode, "%" + filter + "%"};
        String sqlTemp = "select " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_patiend t2 ON t1.patient = t2.code " +
                (isIdcard ? ",wlyy_patient p " : "") +
                " WHERE " +
                (isIdcard ? " t1.patient = p.code  and " : "") +
                "    t1.status > 0 " +
                " AND t1.admin_team_code = ? " +
                "  AND" +
                (isIdcard ? " p.idcard like ? " : " t1.name like ? ");
        String sql = sqlTemp + " order by t2.diseaseCondition,t2.openid desc  limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        String _pdsql = "SELECT p.code,(SELECT sum(d.category_code)  from wlyy_patient_device d WHERE p.code = d.`user`) device from wlyy_patient p";
        patientDeviceTypeMap = jdbcTemplate.queryForMap(_pdsql);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            boolean epTime = false;
                            try {
                                epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            if (!epTime) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", 1);
                            }
                        }
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            jsonP.put("wechatFocusRemind", 0);
                        } else {
                            jsonP.put("wechatFocusRemind", 1);
                        }
                    }
                    continue;
                }
                List<SignPatientLabelInfo> labels = null;
                if (teamCode > 0) {
                    labels = labelInfoDao.findByPatientAndStatusByTeam(sign.get("patient").toString(), 1, teamCode);
                } else {
                    labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                }
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease",p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }
        }
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
}

File diff suppressed because it is too large
+ 281 - 105
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java


+ 19 - 11
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -511,7 +511,7 @@ public class PrescriptionInfoService extends BaseService {
        return 1;
    }
    public JSONArray getDoctorPrescription(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
    public List<Map<String, Object>> getDoctorPrescription(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
@ -522,7 +522,7 @@ public class PrescriptionInfoService extends BaseService {
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor, " +
                " pr.min_drug_day AS minDrugDay," +
                " pr.pres_create_time AS presCreateTime" +
                " LEFT(pr.pres_create_time,19) AS presCreateTime " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` ");
@ -548,7 +548,7 @@ public class PrescriptionInfoService extends BaseService {
            map.put("prescriptionInfo", prescriptionDiagnosisService.getPrescriptionInfo(code));
            map.put("prescriptionDt", prescriptionDiagnosisService.getPrescriptionDiagnosis(code));
        }
        return new JSONArray(rs);
        return rs;
    }
    public void setSQL(StringBuffer pre_sql, List<Object> params, Integer teamCode, String state, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
@ -905,7 +905,14 @@ public class PrescriptionInfoService extends BaseService {
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor, " +
                " pr.dispensary_type AS dispensaryType ," +
                " e.expressage_name AS expressageName " +
                " e.expressage_code AS expressageCode, " +
                " e.expressage_name AS expressageName, " +
                " e.expressage_hospital_address AS expressageHospitalAddress, " +
                " e.expressage_hospital_name AS expressageHospitalName, " +
                " e.expressage_hospital_code AS expressageHospitalCode, " +
                " e.patient_hospital_address AS patientHospitalAddress, " +
                " e.patient_hospital_name AS patientHospitalName, " +
                " e.patient_hospital_code AS patientHospitalCode " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
@ -1052,9 +1059,9 @@ public class PrescriptionInfoService extends BaseService {
        states.add(map4);
        Map<String, Object> map5 = new HashMap<>();
        map2.put("name", "已完成");
        map2.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        states.add(map2);
        map5.put("name", "已完成");
        map5.put("code", PrescriptionLog.PrescriptionLogStatus.finish.getValue());
        states.add(map5);
        //设置配送状态下拉框
        rs.put("states", states);
        //
@ -1264,7 +1271,7 @@ public class PrescriptionInfoService extends BaseService {
            }
        }
        pre_sql.append(" ORDER BY r.reviewed_time DESC ");
        pre_sql.append(" ORDER BY pr.dispensary_type DESC,e.expressage_code ASC,r.reviewed_time DESC ");
        if (page != null && size != null) {
            pre_sql.append(" LIMIT " + (page - 1) * size + "," + size);
        }
@ -1583,9 +1590,10 @@ public class PrescriptionInfoService extends BaseService {
                " d.`code`," +
                " d.`name`," +
                " d.job," +
                " d.photo " +
                " d.photo," +
                " j.name AS jobName " +
                " FROM" +
                " wlyy_doctor d" +
                " wlyy_doctor d  LEFT JOIN dm_job j ON d.job = j.`code`" +
                " WHERE" +
                " d.hospital = ?" +
                " AND d.`level` = 3 " ;
@ -1598,7 +1606,7 @@ public class PrescriptionInfoService extends BaseService {
        String totalSql = "SELECT " +
                " count(1) AS total" +
                " FROM" +
                " wlyy_doctor d" +
                " wlyy_doctor d " +
                " WHERE" +
                " d.hospital = ?" +
                " AND d.`level` = 3 ";

+ 372 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -0,0 +1,372 @@
package com.yihu.wlyy.service.app.scheme;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodPressureDao;
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodSuggerDao;
import com.yihu.wlyy.repository.doctor.DoctroSchemeBloodSuggerDao;
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
/**
 * 医生监测方案相关业务层方法
 * @author huangwenjie
 * @date 2017/9/13 15:46
 */
@Service
public class DoctorSchemeService {
    private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctroSchemeBloodSuggerDao doctroSchemeBloodSuggerDao;
    @Autowired
    private DoctoreSchemeBloodPressureDao doctoreSchemeBloodPressureDao;
    @Autowired
    private JpaTransactionManager transactionManager;
    @Autowired
    private PatientSchemeListDao patientSchemeListDao;
    @Autowired
    private DoctoreSchemeBloodSuggerDao doctoreSchemeBloodSuggerDao;
    /**
     * 根据团队CODE/居民标签/病情/设备绑定状态查询团队具名CODE列表
     * @param teamCode 团队CODE
     * @param disease  病情
     * @param diseaseCondition 居民标签
     * @param deviceType 设备绑定状态
     * @author huangwenjie
     * @date 2017/9/13 16:23
     * @return
     */
    public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, Integer diseaseCondition, Integer deviceType) throws Exception{
        String sql = "select p.code from wlyy_patient p ";
        if(-1 != deviceType){
            sql = sql + " LEFT JOIN wlyy_patient_device dev on dev.user = p.code ";
        }
        sql = sql+ " JOIN wlyy_sign_family sf on sf.patient = p.code where sf.admin_team_code = "+teamCode;
        if(-1 != disease){
            sql = sql + " p.disease ="+disease;
        }
        if(-1 != diseaseCondition){
            sql = sql + " and p.diseaseCondition ="+diseaseCondition;
        }
        if(-1 != deviceType){
            if( 0 == deviceType){
                sql = sql + " and dev.user is null ";
            }else{
                sql = sql + " and dev.user is not null ";
            }
        }
        List<String> result = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
        return result;
    }
    /**
     * 获取医生的血糖监测方案,根据创建时间降序排序,系统方案放最后
     * @param doctorcode
     * @return
     * @throws Exception
     */
    public List<DoctorSchemeBloodSuggerVO> getDoctorScheBloodSuggerList(String doctorcode)  throws Exception {
        List<DoctorSchemeBloodSuggerVO> result = new ArrayList<>();
        HashMap<String,List<DoctorSchemeBloodSugger>> mapresult = new HashMap<>();
        List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
        DoctorSchemeBloodSugger defaultSchemeBloodSugger = doctroSchemeBloodSuggerDao.findByCode("default");
        schemelist.add(defaultSchemeBloodSugger);
        for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
            if(mapresult.keySet().contains(doctorSchemeBloodSugger.getCode())){
                mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
            }else{
                List<DoctorSchemeBloodSugger> list = new ArrayList<>();
                list.add(doctorSchemeBloodSugger);
                mapresult.put(doctorSchemeBloodSugger.getCode(),list);
            }
        }
        for (String key :mapresult.keySet()) {
            DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
            doctorSchemeBloodSuggerVO.setCode(key);
            doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
            doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
            doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
            result.add(doctorSchemeBloodSuggerVO);
        }
        return result;
    }
    /**
     * 获取医生的血压监测方案,根据创建时间降序排序,系统方案放最后
     * @param doctorcode
     * @return
     * @throws Exception
     */
    public  List<DoctorSchemeBloodPressureVO>  getDoctorSchemeBloodPressureList(String doctorcode) throws Exception{
        List<DoctorSchemeBloodPressureVO> result = new ArrayList<>();
        HashMap<String,List<DoctorSchemeBloodPressure>> mapresult = new HashMap<>();
        List<DoctorSchemeBloodPressure> schemelist = doctoreSchemeBloodPressureDao.getListByDoctorcode(doctorcode);
        DoctorSchemeBloodPressure defaultSchemeBloodPressure = doctoreSchemeBloodPressureDao.findByCode("default");
        schemelist.add(defaultSchemeBloodPressure);
        for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
            if(mapresult.keySet().contains(doctorSchemeBloodPressure.getCode())){
                mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
            }else{
                List<DoctorSchemeBloodPressure> list = new ArrayList<>();
                list.add(doctorSchemeBloodPressure);
                mapresult.put(doctorSchemeBloodPressure.getCode(),list);
            }
        }
        for (String key :mapresult.keySet()) {
            DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
            doctorSchemeBloodPressureVO.setCode(key);
            doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
            doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
            doctorSchemeBloodPressureVO.setList(mapresult.get(key));
            result.add(doctorSchemeBloodPressureVO);
        }
        return result;
    }
    /**
     * 医生保存居民的血糖监测方案
     * @param data
     * @throws Exception
     */
    public void saveDoctorSchemeBloodSugger(String data) {
        JSONObject dataObj =  JSON.parseObject(data);
        List<DoctorSchemeBloodSugger> results = new ArrayList<>();
        List<String> patientcodeList = new ArrayList<>();
        String code = dataObj.getString("code");
        if(StringUtils.isBlank(code)){
            code = UUID.randomUUID().toString();
        }
        String name = dataObj.getString("name");
        String content = dataObj.getString("content");
        String doctorcode = dataObj.getString("doctorcode");
        JSONArray datalist = dataObj.getJSONArray("list");
        JSONArray patientcodes = dataObj.getJSONArray("patientcodes");
        for (int i = 0; i < patientcodes.size(); i++) {
            patientcodeList.add(datalist.getJSONObject(i).toString());
        }
        for (int i = 0; i < datalist.size(); i++) {
            DoctorSchemeBloodSugger doctorSchemeBloodSugger = new DoctorSchemeBloodSugger();
            Long id = datalist.getJSONObject(i).getLong("id");
            if(id != 0){
                doctorSchemeBloodSugger.setId(datalist.getJSONObject(i).getLong("id"));
            }
            doctorSchemeBloodSugger.setName(name);
            doctorSchemeBloodSugger.setCode(code);
            doctorSchemeBloodSugger.setDoctorcode(doctorcode);
            doctorSchemeBloodSugger.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
            doctorSchemeBloodSugger.setBeforeBreakfast(datalist.getJSONObject(i).getShort("beforeBreakfast"));
            doctorSchemeBloodSugger.setBeforeBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeBreakfastTime")));
            doctorSchemeBloodSugger.setAfterBreakfast(datalist.getJSONObject(i).getShort("afterBreakfast"));
            doctorSchemeBloodSugger.setAfterBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterBreakfastTime")));
            doctorSchemeBloodSugger.setBeforeLunch(datalist.getJSONObject(i).getShort("beforeLunch"));
            doctorSchemeBloodSugger.setBeforeLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeLunchTime")));
            doctorSchemeBloodSugger.setAfterLunch(datalist.getJSONObject(i).getShort("afterLunch"));
            doctorSchemeBloodSugger.setAfterLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterLunchTime")));
            doctorSchemeBloodSugger.setBeforeDinner(datalist.getJSONObject(i).getShort("beforeDinner"));
            doctorSchemeBloodSugger.setBeforeDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeDinnerTime")));
            doctorSchemeBloodSugger.setAfterDinner(datalist.getJSONObject(i).getShort("afterDinner"));
            doctorSchemeBloodSugger.setAfterDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterDinnerTime")));
            doctorSchemeBloodSugger.setBeforeSleep(datalist.getJSONObject(i).getShort("beforeSleep"));
            doctorSchemeBloodSugger.setBeforeSleepTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeSleepTime")));
            doctorSchemeBloodSugger.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodSugger.setContent(content);
            doctorSchemeBloodSugger.setCreateTime(DateUtil.getNowTimestamp());
            results.add(doctorSchemeBloodSugger);
        }
        if(!results.isEmpty()) {
            //使用事务控制批量更新
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (DoctorSchemeBloodSugger doctorSchemeBloodSugger  : results) {
                    doctoreSchemeBloodSuggerDao.save(doctorSchemeBloodSugger);
                }
                PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode,1,code);
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(code);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    Short _type = new Short("0");
                    patientSchemeListObj.setType(_type);
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {
                //报错事务回滚
                transactionManager.rollback(status);
            }
        }
    }
    /**
     * 医生保存居民的血压监测方案
     * @param data
     * @throws Exception
     */
    public void saveDoctorSchemeBloodPressure(String data) throws Exception{
        JSONObject dataObj =  JSON.parseObject(data);
        List<DoctorSchemeBloodPressure> results = new ArrayList<>();
        List<String> patientcodeList = new ArrayList<>();
        String code = dataObj.getString("code");
        if(StringUtils.isBlank(code)){
            code = UUID.randomUUID().toString();
        }
        String name = dataObj.getString("name");
        String content = dataObj.getString("content");
        String doctorcode = dataObj.getString("doctorcode");
        JSONArray datalist = dataObj.getJSONArray("list");
        JSONArray patientcodes = dataObj.getJSONArray("patientcodes");
        for (int i = 0; i < patientcodes.size(); i++) {
            patientcodeList.add(datalist.getJSONObject(i).toString());
        }
        for (int i = 0; i < datalist.size(); i++) {
            DoctorSchemeBloodPressure doctorSchemeBloodPressure = new DoctorSchemeBloodPressure();
            Long id = datalist.getJSONObject(i).getLong("id");
            if(id != 0){
                doctorSchemeBloodPressure.setId(datalist.getJSONObject(i).getLong("id"));
            }
            doctorSchemeBloodPressure.setName(name);
            doctorSchemeBloodPressure.setCode(code);
            doctorSchemeBloodPressure.setDoctorcode(doctorcode);
            doctorSchemeBloodPressure.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
            doctorSchemeBloodPressure.setEarlyMorning(datalist.getJSONObject(i).getShort("earlyMorning"));
            doctorSchemeBloodPressure.setEarlyMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("earlyMorningTime")));
            doctorSchemeBloodPressure.setMorning(datalist.getJSONObject(i).getShort("morning"));
            doctorSchemeBloodPressure.setMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("morningTime")));
            doctorSchemeBloodPressure.setNoon(datalist.getJSONObject(i).getShort("noon"));
            doctorSchemeBloodPressure.setNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("noonTime")));
            doctorSchemeBloodPressure.setAfterNoon(datalist.getJSONObject(i).getShort("afterNoon"));
            doctorSchemeBloodPressure.setAfterNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterNoonTime")));
            doctorSchemeBloodPressure.setNight(datalist.getJSONObject(i).getShort("night"));
            doctorSchemeBloodPressure.setNightTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("nightTime")));
            doctorSchemeBloodPressure.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodPressure.setContent(content);
            doctorSchemeBloodPressure.setCreateTime(DateUtil.getNowTimestamp());
            results.add(doctorSchemeBloodPressure);
        }
        if(!results.isEmpty()) {
            //使用事务控制批量更新
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : results) {
                    doctoreSchemeBloodPressureDao.save(doctorSchemeBloodPressure);
                }
                PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode,0,code);
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(code);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    Short _type = new Short("0");
                    patientSchemeListObj.setType(_type);
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {
                //报错事务回滚
                transactionManager.rollback(status);
            }
        }
    }
}

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

@ -28,6 +28,7 @@ import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;
@ -128,6 +129,8 @@ public class FamilyContractService extends BaseService {
    private SignFamilyRenewDao signFamilyRenewDao;
    @Autowired
    private SignFamilyMappingDao signFamilyMappingDao;
    @Autowired
    private JwArchivesService jwArchivesService;
    @Autowired
    private ImUtill ImUtill;
@ -4055,4 +4058,13 @@ public class FamilyContractService extends BaseService {
        Integer patients = jdbcTemplate.queryForObject(sb.toString(), params.toArray(), Integer.class);
        return patients;
    }
    public String getSickArchiveFlag(String patient)throws Exception{
        Patient p = patientDao.findByCode(patient);
        String rs = jwArchivesService.getSickArchiveFlag(p.getIdcard());
        return rs ;
    }
}

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

@ -139,7 +139,7 @@ public class DoctorService extends TokenService {
    }
    public Integer findDoctorCounts(String hospitalCode,String doctorName,Integer level) {
        String sql = "select * from wlyy_doctor where del=1 and status=1   ";
        String sql = "select count(*) from wlyy_doctor where del=1 and status=1   ";
        List<Object> args = new ArrayList<>();
        if (!org.springframework.util.StringUtils.isEmpty(hospitalCode)) {
            sql += " and hospital = ? ";

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

@ -24,7 +24,6 @@ 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.apache.commons.lang3.time.DateUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -36,8 +35,6 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.utils.Clock;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -789,7 +786,7 @@ public class PatientService extends TokenService {
     *
     * @return
     */
    public JSONArray getSignByDoctorCodeGpbyServer(String doctor, String teamCode) {
    public JSONArray getSignByDoctorCodeGpbyServer(String doctor, String teamCode, boolean isSlowDisease) {
        String teamCodeSql = "";
        if (!org.springframework.util.StringUtils.isEmpty(teamCode)) {
            teamCodeSql = " and f.admin_team_code=" + teamCode + " ";
@ -831,7 +828,6 @@ public class PatientService extends TokenService {
        List<Map<String, Object>> totalG = jdbcTemplate.queryForList(totalGSql);
        //获取关注量分组数量
        String fousGSql = "SELECT " +
                " d.`code` AS serverType, " +
                " d.`name` AS serverTypeName, " +
@ -849,9 +845,15 @@ public class PatientService extends TokenService {
                "   FROM " +
                "    wlyy_sign_family f ,wlyy_patient p " +
                "   WHERE " +
                "   f.patient = p.code " +
                "   AND p.openid IS NOT NULL " +
                "   AND p.openid <>'' " +
                "   f.patient = p.code ";
        if(isSlowDisease){
            //获取预警分组数量
            fousGSql = fousGSql +"   AND p.standard_status = 1 ";
        }else{
            //获取微信关注量分组数量
            fousGSql = fousGSql +"   AND p.openid IS NOT NULL AND p.openid <>'' " ;
        }
        fousGSql = fousGSql +
                "   AND ( " +
                "     f.doctor = '" + doctor + "' " +
                "     OR f.doctor_health = '" + doctor + "' " +

+ 275 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -0,0 +1,275 @@
package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 医生助手相关模板消息
 * <p>
 * Created by Reece on 2017/9/7/007.
 */
public class DoctorFeldsherTemplateService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private ImUtill imUtill;
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateService.class);
    /**
     * 医生为居民设置监测方案后实时为居民推送信息变更通知消息提醒
     *
     * @param patient 居民code
     * @param url     带参数的跳转URL
     * @throws Exception
     */
    public void sendChangeTemplate(String patient, String url) throws Exception {
        Patient people = patientDao.findByCode(patient);
        String openId = people.getOpenid();
        String name = people.getName();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONArray jsonArray = null;
        JSONObject sendJson = new JSONObject();
        String first = name + "您好,您的家庭医生已为您设置了血糖(血压)监测方案,请按照方案及时测量及上传您的体征数据。";
        String remark = "您可使用详情查看方案内容";
        sendJson.put("keyword1", name);
        sendJson.put("keyword2", dateFormat.format(new Date()));
        sendJson.put("keyword3", "血糖(血压)监测方案");
        sendJson.put("first", first);
        sendJson.put("remark", remark);
        sendJson.put("url", url);//带参数的模板跳转链接
        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, openId, name, sendJson);
        //发送代理人
        jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
        if (jsonArray != null && jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject j = jsonArray.getJSONObject(i);
                Patient member = (Patient) j.get("member");
                int start = url.indexOf("&toUser=");
                int end = url.indexOf("&", start + 1);
                String touser = url.substring(start, end);
                url = url.replace(touser, "&toUser=" + member.getCode());
                //name患者姓名
                sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                sendJson.put("url", url);
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, member.getOpenid(), name, sendJson);
            }
        }
        logger.info("sendJson: " + sendJson);
    }
    /**
     * 发送给医生的模板消息提醒
     *
     * @param patientCode 居民code
     * @param doctorCode  医生code
     * @throws Exception
     */
    public void sendDoctorTemplate(String patientCode, String doctorCode, int type) throws Exception {
        int num = 0;
        int num1 = 0;
        int num2 = 0;
        int num3 = 0;
        int num4 = 0;
        int num5 = 0;
        int num6 = 0;
        Date date = new Date();
        Date date1 = new Date();
        String content1 = "";
        String contetn2 = "";
        Patient people = patientDao.findByCode(patientCode);
        String patientOpenId = people.getOpenid();
        String patientName = people.getName();
        int patientSex = people.getSex();
        Doctor doctor = doctorDao.findByCode(doctorCode);
        String doctorName = doctor.getName();
        String doctorOpenId = doctor.getOpenid();
        //使用微信应用宝跳转APP的功能。点击后跳转APP消息页。
        String url = "";
        String first = "";
        String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        JSONObject sendJson = new JSONObject();
        switch (type) {
            case 1:
                first = doctorName + "医生您好,你有一条新的签约申请待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 2:
                first = doctorName + "医生,您的签约居民" + patientName + "有" + num + "条未读的体征异常消息";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 3:
                first = doctorName + "医生您好。" + date + "新增1个签约居民待分配健管师,截至目前共有 " + num1 + " 人待处理";
                sendJson.put("keyword1", "分配健管师");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 4:
                first = "您今日有" + num3 + "个随访计划待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 5:
                first = doctorName + "医生您好,有患者向您发起咨询";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", patientSex == 1 ? "男" : "女");
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 6:
                first = "居民" + patientName + "的健康咨询有新的回复";
                sendJson.put("keyword1", content1);
                sendJson.put("keyword2", contetn2);
                sendJson.put("keyword3", doctorName);
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 7:
                first = doctorName + "医生您好。您的签约居民" + patientName + "申请线上续方,请尽快审核";
                sendJson.put("keyword1", "续方审核");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 8:
                first = doctorName + "医生您好。" + date1 +
                        "新增1个续方订单待分配配送员,目前共" + num4 +
                        "人待分配,一个尽快分配";
                sendJson.put("keyword1", "分配配送员");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 9:
                first = doctorName + "医生您好。您有一个您有1个续方申请处方开立失败";
                sendJson.put("keyword1", doctorName);
                sendJson.put("keyword2", patientName);
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 10:
                first = doctorName + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证";
                sendJson.put("keyword1", "续方审核CA认证");
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
            case 11:
                first = doctorName + "医生您好,你有一条新的续签申请待处理";
                sendJson.put("keyword1", patientName);
                sendJson.put("keyword2", dateFormat.format(new Date()));
                sendJson.put("first", first);
                sendJson.put("remark", remark);
                sendJson.put("url", url);//带参数的模板跳转链接
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 0, doctorOpenId, doctorName, sendJson);
                logger.info("sendJson: " + sendJson);
                break;
        }
    }
    /**
     *  拼装医生助手 医生类模板消息并发送
     * @param doctorCode 医生code
     * @param sessionId 会话Id
     * @param sessionType 会话类型
     * @param businessType 消息类型
     * @param from 发送者
     * @param content 消息内容
     * @return
     */
    public Boolean sendDoctorTemplate(String doctorCode, String sessionId, String sessionType, String businessType, String from, String content) {
        try {
            String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
            String url = "www.baidu.com";
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
            JSONObject sendJson = new JSONObject();
            Doctor doctor = doctorDao.findByCode(doctorCode);
            String doctorName = doctor.getName();
            String doctorOpenId = doctor.getOpenid();
            String first = businessType;
            sendJson.put("keyword1", content);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, doctorOpenId, doctorName, sendJson);
            logger.info("sendJson: " + sendJson);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}

+ 265 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/fzzb/HealthEducationArticleService.java

@ -0,0 +1,265 @@
package com.yihu.wlyy.service.third.fzzb;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * 福州总部-健康教育医生APP接口文档
 * 文档地址- http://sso.yihu.cn/DWeb/wiki/wz.html?id=CF5D09684702481BA70F84142817A639
 * Created by yeshijie on 2017/9/11.
 */
@Service
public class HealthEducationArticleService extends BaseService{
    private static Logger logger = LoggerFactory.getLogger(HealthEducationArticleService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private DoctorDao doctorDao;
    private String baseUrl = "http://service.yihu.com:8085/WsPlatform/rest";
    @Value("${yihu.yihu_OpenPlatform_appId}")
    private String clientId;
    private String clientVersion = "1.0";
    private String getArticalById = "JkEdu.Article.getArticalById";//获取单篇文章详情
    private String getDoctorArticalList = "JkEdu.Article.getDoctorArticalList";//获取卫计委认证文章+医生发表未认证文章
    private String getCollectionArticalList = "JkEdu.Article.getCollectionArticalList";//获取收藏文章列表
    private String getCategoryList = "JkEdu.Category.getCategoryList";//获取类别接口
    private String cancelArticleCollection = "JkEdu.Behavior.cancelArticleCollection";//取消收藏接口
    private String saveArticleCollection = "JkEdu.Behavior.saveArticleCollection";//医生收藏接口
    private String getDoctorArticalByUserId = "JkEdu.Behavior.getDoctorArticalByUserId";//医生发表文章接口
    /**
     * 封装入参
     * @param api
     * @param param
     * @param version
     * @return
     */
    public Map<String,String> getParamsMap(String api,String param,String version){
        Map<String,String> params = new HashMap<>();
        JSONObject authInfo = new JSONObject();
        authInfo.put("clientId",clientId);//填渠道ID(必填,固定为9000276)
        authInfo.put("clientVersion",clientVersion);//接入方系统版本号(非必须,默认 1.0)
        authInfo.put("sign","");//(保留,非必填)
        authInfo.put("sessionKey","");//(保留,非必填)
        params.put("AuthInfo",authInfo.toString());
        params.put("SequenceNoString", DateUtil.getUserDate(DateUtil.YYYYMMddHHmmssSSS));//请求序列号,yyyyMMddHHmmssSSS 格式的时间戳
        params.put("Api",api);//Api 名称    需要调用的 API 名称
        params.put("Param",param);//本次请求的方法参数   Json结构的字符串
        params.put("ParamType","0");//指定 param 参数的类型,固定传0
        params.put("OutType","0");//指定返回 JSON/Xml 结构的字符串,固定传0
        params.put("V",version);//API 版本号。版本号为整型,从数字 1 开始递增.
        return params;
    }
    /**
     * 获取文章列表
     * @param articleTitle 否 文章标题
     * @param articleState 否 传1
     * @param firstLevelCategoryId 否    一级类别ID ,多个逗号隔开
     * @param pageIndex 否    起始页数 0开始,默认0
     * @param pageSize 否    每页显示数 ,默认5
     * @param userId 是    当前用户ID
     * @return
     */
    public String getDoctorArticalList(String articleTitle, Integer articleState, String firstLevelCategoryId, Integer pageIndex, Integer pageSize,String userId){
        String response = "";
        try{
            JSONObject param = new JSONObject();
            param.put("articleTitle",articleTitle);
            param.put("articleState",articleState);
            param.put("firstLevelCategoryId",firstLevelCategoryId);
            param.put("pageIndex",pageIndex);
            param.put("pageSize",pageSize);
            param.put("userId",userId);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap(getDoctorArticalList,param.toString(),"1"));
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 获取文章详情
     * @param articleId 文章id
     * @return
     */
    public String getArticalById(String articleId){
        String response = "";
        try{
            JSONObject param = new JSONObject();
            param.put("articleId",articleId);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap(getArticalById,param.toString(),"1"));
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 获取收藏文章列表
     * @param articleTitle 否 文章标题
     * @param articleState 否 传1
     * @param firstLevelCategoryId 否    一级类别ID ,多个逗号隔开
     * @param pageIndex 否    起始页数 0开始,默认0
     * @param pageSize 否    每页显示数 ,默认5
     * @param userId 是    当前用户ID
     * @param userType 是    1 医生 2 居民
     * @return
     */
    public String getCollectionArticalList(String articleTitle, Integer articleState, String firstLevelCategoryId, Integer pageIndex, Integer pageSize,String userId,Integer userType){
        String response = "";
        try{
            JSONObject param = new JSONObject();
            param.put("articleTitle",articleTitle);
            param.put("articleState",articleState);
            param.put("firstLevelCategoryId",firstLevelCategoryId);
            param.put("pageIndex",pageIndex);
            param.put("pageSize",pageSize);
            param.put("userId",userId);
            param.put("userType",userType);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap(getCollectionArticalList,param.toString(),"1"));
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 获取文章类别
     * @param categoryLevel 是    获取类别:1、一级类别 2、二级类别
     * @return
     */
    public String getCategoryList(String categoryLevel) throws Exception{
        String response = "";
        try{
            JSONObject param = new JSONObject();
            param.put("categoryLevel",categoryLevel);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap(getCategoryList,param.toString(),"1"));
            JSONObject json = JSON.parseObject(response);
            if("10000".equals(json.getString(""))){
            }
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 取消收藏文章
     * @param articleId 是 文章id
     * @param userId 是    当前用户ID
     * @param userType 是    1 医生 2 居民
     * @return
     */
    public String cancelArticleCollection(String articleId,String userId,Integer userType){
        String response = "";
        try{
            JSONObject param = new JSONObject();
            param.put("articleId",articleId);
            param.put("userId",userId);
            param.put("userType",userType);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap(cancelArticleCollection,param.toString(),"1"));
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 收藏文章列表
     * @param articleId 文章id
     * @param articleCategoryId 文章类别ID
     * @param articleCategoryName 文章类别名称
     * @param userId 是    当前用户ID
     * @param userType 是    1 医生 2 居民
     * @return
     */
    public String saveArticleCollection(String articleId, String articleCategoryId, String articleCategoryName,String userId,Integer userType){
        String response = "";
        try{
            Doctor doctor = doctorDao.findByCode(userId);
            String orgName = doctor.getHospitalName();//用户所属机构
            String orgId = doctor.getHospital();//用户所属机构ID
            String cName = doctor.getName();//用户名
            JSONObject param = new JSONObject();
            param.put("articleId",articleId);
            param.put("cName",cName);
            param.put("articleCategoryId",articleCategoryId);
            param.put("articleCategoryName",articleCategoryName);
            param.put("orgName",orgName);
            param.put("orgId",orgId);
            param.put("userId",userId);
            param.put("userType",userType);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap(saveArticleCollection,param.toString(),"1"));
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 获取医生发表的文章列表
     * @param articleTitle 否 文章标题
     * @param articleState 否 传1
     * @param firstLevelCategoryId 否    一级类别ID ,多个逗号隔开
     * @param pageIndex 否    起始页数 0开始,默认0
     * @param pageSize 否    每页显示数 ,默认5
     * @param userId 是    当前用户ID
     * @return
     */
    public String getDoctorArticalByUserId(String articleTitle, Integer articleState, String firstLevelCategoryId, Integer pageIndex, Integer pageSize,String userId){
        String response = "";
        try{
            JSONObject param = new JSONObject();
            param.put("articleTitle",articleTitle);
            param.put("articleState",articleState);
            param.put("firstLevelCategoryId",firstLevelCategoryId);
            param.put("pageIndex",pageIndex);
            param.put("pageSize",pageSize);
            param.put("userId",userId);
            response = httpClientUtil.httpPost(baseUrl,getParamsMap(getDoctorArticalByUserId,param.toString(),"1"));
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return response;
    }
}

+ 144 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -805,4 +804,148 @@ public class JwArchivesService {
            throw new Exception("返回结果为空!");
        }
    }
    /*****************************************建档相关******************************************************************/
    /**
     *  查询居民是否有建立健康档案接口
     */
    public String getSickArchiveFlag(String idcard)  throws Exception
    {
        String re = "0";//0 未建档,非0为档案号
        String url = jwUrl + "/third/archives/getSickArchiveFlag";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else{
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        re = jsonArray.getJSONObject(0).getString("ARCHIVE_ID");
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
    /**
     * 查询居民健康档案信息接口
     * @param idcard
     * @return
     * @throws Exception
     */
    public JSONArray getSickArchiveRecord(String idcard)  throws Exception
    {
        JSONArray re = new JSONArray();
        String url = jwUrl + "/third/archives/getSickArchiveRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else{
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        // {"ARCHIVE_ID":"档案ID","SICK_NAME":"病人姓名","SICK_SEX":"性别","BIRTHDAY":"出生日期","IDENTITY_CARD_NO":"身份证号码","ZONE_CODE":"归属辖区","HOME_ADDRESS":"现住址","INSUR_CARD_NO":"医保卡号"}
                        jsonArray.forEach(one->{
                            JSONObject jsonObject = new JSONObject(one);
                            JSONObject js = new JSONObject();
                            js.put("archiveId",jsonObject.get("ARCHIVE_ID"));
                            js.put("sickName",jsonObject.get("SICK_NAME"));
                            js.put("sickSex",jsonObject.get("SICK_SEX"));
                            js.put("birthday",jsonObject.get("BIRTHDAY"));
                            js.put("idCard",jsonObject.get("IDENTITY_CARD_NO"));
                            js.put("zoneCode",jsonObject.get("ZONE_CODE"));
                            js.put("homeAddress",jsonObject.get("HOME_ADDRESS"));
                            js.put("ssc",jsonObject.get("INSUR_CARD_NO"));
                            re.put(js);
                        });
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
    /**
     * 上传居民档案建档信息接口
     * @param param 入参json对象,成功返回档案号
     * @param doctor
     * @return
     */
    public String saveSickArchiveRecord(String param,String doctor) throws Exception{
        String re = "0";//0 未建档,非0为档案号
        String url = jwUrl + "/third/archives/saveSickArchiveRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("json", param));
        params.add(new BasicNameValuePair("doctor", doctor));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if(!StringUtils.isEmpty(response))
        {
            JSONObject json = new JSONObject(response);
            if (!"200".equals(json.optString("status"))) {
                throw new Exception(json.optString("msg"));
            }else{
                String dataStr = json.getString("data");
                if(!StringUtils.isEmpty(dataStr)){
                    JSONObject data = new JSONObject(dataStr);
                    if("1".equals(data.optString("CODE")))
                    {
                        JSONArray jsonArray = data.getJSONArray("DATA");
                        re = jsonArray.getJSONObject(0).getString("ARCHIVE_ID");
                    }
                    else{
                        throw new Exception(json.optString("MESSAGE"));
                    }
                }else{
                    throw new Exception("返回结果为空!");
                }
            }
        }
        else{
            throw new Exception("返回结果为空!");
        }
        return re;
    }
}

+ 0 - 129
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java

@ -1,129 +0,0 @@
package com.yihu.wlyy.service.weixin.wxpay.common;
import org.springframework.context.annotation.Configuration;
/**
 * User: hzp
 * Date: 20170518
 * 这里放置各种配置数据
 */
@Configuration
public class Configure {
	/******************************* 易联众统一支付平台 ***********************************************************/
//	private String onepayApi = "http://120.42.37.94:1301/onepay-web/";
//	private String onepayAppId = "1BGKM1UHM03P7B2CA8C000005626EB0E";
//	private String onepayAppSecret = "1BGKM1UHM03I7B2CA8C00000AB682E9A";
//			开发环境应用信息
//	private String onepayApi = "https://xmhealth.ylzpay.com:8080/";
	private String onepayApi = "http://xmhealth.ylzpay.com:8070/";
	private String onepayAppId = "1BLF5SEGN00087165F0A000027362BE5";
	private String onepayAppSecret = "1BLF5SCBO01V3E78A8C00000F3A0FFE7";
	private String bindCardType = "onepay.sicard.bind.info";
	private String chargeType = "onepay.trade.medical.charge";
	private String chargeQueryType = "onepay.trade.medical.charge.query";
	private String createSicardType = "onepay.sicard.createurl";
//	易联众异步回调
	private String receiveNotify = "wlyy.onepay.receiveNotify";
	private String returnUrl = "wlyy.onepay.returnUrl";
//  长处方系列
	private String recipeChargeType = "onepay.trade.long.recipe.charge";
	private String recipeReturnUrl = "wlyy.patient.prescription.pay.recipeReturnUrl";
	private String receiveRecipeNotify = "wlyy.patient.prescription.pay.receiveRecipeNotify";
	public String getRecipeChargeType() {
		return recipeChargeType;
	}
	public void setRecipeChargeType(String recipeChargeType) {
		this.recipeChargeType = recipeChargeType;
	}
	public String getRecipeReturnUrl() {
		return recipeReturnUrl;
	}
	public void setRecipeReturnUrl(String recipeReturnUrl) {
		this.recipeReturnUrl = recipeReturnUrl;
	}
	public String getReceiveRecipeNotify() {
		return receiveRecipeNotify;
	}
	public void setReceiveRecipeNotify(String receiveRecipeNotify) {
		this.receiveRecipeNotify = receiveRecipeNotify;
	}
	public String getReturnUrl() {
		return returnUrl;
	}
	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}
	public String getReceiveNotify() {
		return receiveNotify;
	}
	public void setReceiveNotify(String receiveNotify) {
		this.receiveNotify = receiveNotify;
	}
	public String getOnepayApi() {
		return onepayApi;
	}
	public String getOnepayAppId() {
		return onepayAppId;
	}
	public String getOnepayAppSecret() {
		return onepayAppSecret;
	}
	public String getBindCardType() {
		return bindCardType;
	}
	public String getChargeType() {
		return chargeType;
	}
	public String getChargeQueryType() {
		return chargeQueryType;
	}
	public String getCreateSicardType() {
		return createSicardType;
	}
	/******************* 微信社保支付配置 ******************************************/
	//这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
	// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
	// 收到API的返回的时候也要用这个key来对返回的数据算下签名,跟API的Sign数据进行比较,如果值不一致,有可能数据被第三方给篡改
	private String key = "2935b54b53a957d9516c920a544f2537";
	//微信分配的公众号ID(开通公众号之后可以获取到)
	private String appID = "wxd03f859efdf0873d";
	public String getKey(){
		return key;
	}
	public String getAppid(){
		return appID;
	}
	//获取token地址
	public String TOKEN_API = "https://api.weixin.qq.com/payinsurance/gettoken";
	//挂号/诊间支付统一下单 API 接口
	public String ORDER_API = "https://api.weixin.qq.com/payinsurance/unifiedorder?access_token ACCESS_TOKEN";
}

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/model/BindCard.java

@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;

+ 114 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -9,13 +9,14 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.util.SystemConf;
@ -24,7 +25,6 @@ import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,7 +47,7 @@ import java.util.*;
public class OnePayService {
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private LogService logService;
@ -137,6 +137,7 @@ public class OnePayService {
        String error = "";
        List<BindCard> result = new ArrayList<BindCard>();
        PayConfigura config = configuraDao.findWorkConfigura();
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
@ -218,6 +219,7 @@ public class OnePayService {
        String result = "";
        String channel = "WX_MMP";   //  医保支付渠道
        String subject = "家庭医生签约支付";   //  订单名称
        PayConfigura config = configuraDao.findWorkConfigura();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
//     未真正完成支付以前预存储支付信息到wlyy_charge表
@ -326,6 +328,8 @@ public class OnePayService {
            Map<String, String> map = new HashMap<>();
            map.put("feeType", "04");//家庭医生签约
            map.put("settleType", "03"); //健康账户支付
            //易联众新增字段v1.3.7
            map.put("principalCardNo", ssc); //实际签约卡号( 默认为绑卡主体卡号)
            params.put("requestContent", objectMapper.writeValueAsString(map));// 请求结构体
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
@ -373,6 +377,7 @@ public class OnePayService {
        String response = "";
        String error = "";
        String result = null;
        PayConfigura config = configuraDao.findWorkConfigura();
        WlyyCharge charge = chargeDao.findByCode(code);
        HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
@ -408,7 +413,109 @@ public class OnePayService {
//                result = JSON.toJavaObject(res.getParam(), Charge.class);
                result = JSON.toJSONString(res.getParam());
//                 返回医保机构体
//                 新增保存数据
                JSONObject request = JSON.parseObject(result);
//                String tradeStatus = request.getString("tradeStatus");//交易状态
                String chargeStatus = request.getString("chargeStatus");//交易状态
                String chargeNo = request.getString("chargeNo");//支付平台流水号
                String chargeTime = request.getString("chargeTime");//支付平台交易成功时间
                String outChargeNo = request.getString("outChargeNo");//接入应用业务流水号
                String outChargeTime = request.getString("outChargeTime");//接入应用时间
                String medOrgNo = request.getString("medOrgNo");//医疗机构编号
                String medOrgName = request.getString("medOrgName");//医疗机构名称
                String billNo = request.getString("billNo");//待结算费用单据号
                String cardNo = request.getString("cardNo");//医保卡号
                String totalAmount = request.getString("totalAmount");//交易总金额
                String insuranceAmount = request.getString("insuranceAmount");//医保支付金额
                String selfPayAmount = request.getString("selfPayAmount");//自付金额
                String userId = request.getString("userId");//用户openID
                String userName = request.getString("userName");//用户名字
                String idNo = request.getString("idNo");//证件号码
                String idType = request.getString("idType");//证件类型
//                String appId = request.getString("appId");
//                String channel = request.getString("channel");//支付方式
//                String sign = request.getString("sign");
//                String signType = request.getString("signType");
//                String timestamp = request.getString("timestamp");
                JSONObject responseContents = request.getJSONObject("responseContent");//医保结构体
                WlyyCharge prescriptionPay = chargeDao.findByCode(outChargeNo);
                if (responseContents != null) {
                    String miRegisterNo = responseContents.getString("miRegisterNo");//医保挂号
                    String miCollectDate = responseContents.getString("miCollectDate");//收费日期
                    String miCollectTime = responseContents.getString("miCollectTime");//收费时间
                    String miSettleNo = responseContents.getString("miSettleNo");//医保收费单据号 (医保签约号)
                    String miCollectStatus = responseContents.getString("miCollectStatus");//扣费状态
                    String miRegisterStatus = responseContents.getString("miRegisterStatus");//登记状态
                    String cadresPay = responseContents.getString("cadresPay");//公务员补助
                    String miTotalFee = responseContents.getString("miTotalFee");//本次报销总额
                    String healthCarePay = responseContents.getString("healthCarePay");//保健基金支付
                    String heathPay = responseContents.getString("heathPay");//健康账户支付
                    String accountPay = responseContents.getString("accountPay");//个人账户支付
                    String selfPay = responseContents.getString("selfPay");//个人现金支付
                    String civilPay = responseContents.getString("civilPay");//民政补助金额
                    /*String miCollectorName = responseContents.getString("miCollectorName");//收费人姓名
                    String fundPay = responseContents.getString("fundPay");//基金支付
                    String commercePay = responseContents.getString("commercePay");//商业保险支付
                    String familyPay = responseContents.getString("familyPay");//共济账户支付
                    String civilZone = responseContents.getString("civilZone");//民政行政区号
                    String bdrugPay = responseContents.getString("bdrugPay");//乙类支付金额
                    String unlessAmount = responseContents.getString("unlessAmount");//非医保费用
                    String exceedAmount = responseContents.getString("exceedAmount");//超封顶线金额
                    String accountBalance = responseContents.getString("accountBalance");//个人账户余额
                    String healthBalance = responseContents.getString("healthBalance");//健康账户余额*/
                    prescriptionPay.setMiRegisterNo(miRegisterNo);//医保挂号
                    /*prescriptionPay.setMiSettleNo(miSettleNo);//医保收费单据号
                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMdd");
                    prescriptionPay.setMiCollectDate(formatDate.parse(miCollectDate));//收费日期
                    SimpleDateFormat formatTime = new SimpleDateFormat("HHmm");
                    prescriptionPay.setMiCollectTime(formatTime.parse(miCollectTime));//收费时间
                    prescriptionPay.setMiCollectorName(miCollectorName);//收费人姓名
                    prescriptionPay.setMiTotalFee(Integer.parseInt(miTotalFee));//本次报销总额
                    prescriptionPay.setSelfPay(Integer.parseInt(selfPay));//个人现金支付
                    prescriptionPay.setAccountPay(Integer.parseInt(accountPay));//个人账户支付
                    prescriptionPay.setHeathPay(Integer.parseInt(heathPay));//健康账户支付
                    prescriptionPay.setCadresPay(Integer.parseInt(cadresPay));//公务员补助
                    prescriptionPay.setFundPay(Integer.parseInt(fundPay));//基金支付
                    prescriptionPay.setHealthCarePay(Integer.parseInt(healthCarePay));//保健基金支付
                    prescriptionPay.setCommercePay(Integer.parseInt(commercePay));//商业保险支付
                    prescriptionPay.setFamilyPay(Integer.parseInt(familyPay));//共济账户支付
                    prescriptionPay.setCivilPay(Integer.parseInt(civilPay));//民政补助金额
                    prescriptionPay.setCivilZone(civilZone);//民政行政区号
                    prescriptionPay.setBdrugPay(Integer.parseInt(bdrugPay));//乙类支付金额
                    prescriptionPay.setUnlessAmount(Integer.parseInt(unlessAmount));//非医保费用
                    prescriptionPay.setExceedAmount(Integer.parseInt(exceedAmount));//超封顶线金额
                    prescriptionPay.setAccountBalance(Integer.parseInt(accountBalance));//个人账户余额
                    prescriptionPay.setHealthBalance(Integer.parseInt(healthBalance));//健康账户余额*/
                }
                if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
                    prescriptionPay.setTradeStatus("1");//交易状态 成功1 失败0
                }else {
                    prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                }
                prescriptionPay.setChargeNo(chargeNo);//支付流水号
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
                prescriptionPay.setChargeTime(chargeTime);//支付平台交易成功时间
//                prescriptionPay.setOutChargeTime(formatDate.parse(outChargeTime));//接入应用内业务时间
                prescriptionPay.setMedOrgNo(medOrgNo);//医疗机构编号
                prescriptionPay.setMedOrgName(medOrgName);//医疗机构名称
                prescriptionPay.setBillNo(billNo);//待结算费用单据号
                prescriptionPay.setSsc(cardNo);//医保卡号
                prescriptionPay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
                prescriptionPay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
                prescriptionPay.setSelfpayAmount(Integer.parseInt(selfPayAmount));//自付金额
                prescriptionPay.setOpenid(userId);
                prescriptionPay.setName(userName);
                prescriptionPay.setIdType(idType);//证件类型
                prescriptionPay.setIdNo(idNo);//证件号码
                //        保存数据库更改记录
                chargeDao.save(prescriptionPay);
//                System.out.println("请求成功,返回参数:" + result.getTradeStatus() + "  " + result.getUserName());
                LOGGER.info("请求成功,返回参数: "+result);
@ -443,6 +550,7 @@ public class OnePayService {
        String response = "";
        String error = "";
        String result = "";
        PayConfigura config = configuraDao.findWorkConfigura();
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
@ -461,6 +569,8 @@ public class OnePayService {
            JSONObject params = new JSONObject();
            params.put("openId", openid);
            params.put("accId", accId);  //微信公众号开发者ID
//           易联众新增字段代支付v1.3.7
            params.put("createType", "sicard");  //生成类型 sicard 个人电子社保卡 OR family 家庭成员绑卡 ( 默认 sicard)
            requestParams.setParam(params);
            requestParams.setTransType(config.getCreateSicardType());

+ 22 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.*;
import java.text.DecimalFormat;
@Component
public class CommonUtil {
    @Value("${fastDFS.fastdfs_file_url}")
@ -347,5 +349,25 @@ public class CommonUtil {
        return null;
    }
    /**
     * 传入身高体重,计算BMI值
     * @param weightStr 体重
     * @param heightStr 身高
     * @return
     */
    public double getBMIByWeightAndHeight(String weightStr,String heightStr){
        DecimalFormat df2 = new DecimalFormat("###.00");
        double weight = Double.parseDouble(weightStr);
        Integer heightCM = Integer.parseInt(heightStr);
        heightStr = df2.format(heightCM/100d);
        double height = Double.parseDouble(heightStr);
        double bmi = weight / height * 2;
        return bmi;
    }
}

+ 31 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.util;
import org.apache.commons.lang3.StringUtils;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
@ -20,6 +22,7 @@ public class DateUtil {
	public static final String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public static final String YYYY_M_D_HH_MM_SS = "yyyy/M/d HH:mm:ss";
	public static final String YYYYMMddHHmmssSSS  = "yyyyMMddHHmmssSSS";
	/**
@ -30,11 +33,6 @@ public class DateUtil {
		return formatter.format(date);
	}
	/*public static void main(String[] args)
	{
	   System.out.print(dateToChinese(new Date()));
	}*/
	/**
	 * 字符串转时间格式
	 */
@ -844,4 +842,32 @@ public class DateUtil {
		cal.add(Calendar.DAY_OF_YEAR,day);
		return cal.getTime();
	}
	/**
	 * 将HH:MM格式的字符串转TIME
	 * @param hhmm
	 * @return
	 */
	public static Time hhmmStrToTime(String hhmm){
		Time time = null;
		DateFormat sdf = new SimpleDateFormat("hh:mm");
		try {
			Date date = sdf.parse(hhmm);
			time = new Time(date.getTime());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return time;
	}
	/**
	 * 获取当前时间的Timestamp
	 * @return
	 */
	public static Timestamp getNowTimestamp(){
		Date date = new Date();
		Timestamp nousedate = new Timestamp(date.getTime());
		return nousedate;
	}
}

+ 54 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -140,6 +140,39 @@ public class ImUtill {
        return response;
    }
    /**
     * 咨询列表总数
     * @param user
     * @param status status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
     * @param reply
     * @param type 1、三师咨询,2、家庭医生咨询,6、患者名医咨询 7医生名医咨询 8续方咨询 10医生发起的求助
     * @return
     */
    public String getConsultCountByStatusAndType(String user,Integer status,Integer reply,Integer type,String patientName,String startTime,String endTime){
        String imAddr = im_host + "api/v2/sessions/topicListCountByType";
        imAddr = imAddr + "?user="+user;
        if (status != null) {
            imAddr += ("&status=" + status);
        }
        if (reply != null) {
            imAddr += ("&reply=" + reply);
        }
        if (type != null) {
            imAddr += ("&type=" + type);
        }
        if (patientName != null) {
            imAddr += ("&patientName=" + patientName);
        }
        if (startTime != null) {
            imAddr += ("&startTime=" + startTime);
        }
        if (endTime != null) {
            imAddr += ("&endTime=" + endTime);
        }
        String response = HttpClientUtil.get(imAddr, "UTF-8");
        return response;
    }
    /**
     * 发送消息给IM
     *
@ -160,6 +193,27 @@ public class ImUtill {
        return response;
    }
    /**
     * 发送消息给IM(发送给医生的,医生会多发送医生助手微信模板消息)
     *
     * @param from        来自
     * @param contentType 1文字 2图片消息
     * @param content     内容
     */
    public String sendDoctorImMsg(String from, String fromName, String sessionId, String contentType, String content, String businessType,String sendJson) {
        String imAddr = im_host + "api/v2/sessions/" + sessionId + "/messages";
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("sender_name", fromName);
        params.put("content_type", contentType);
        params.put("content", content);
        params.put("session_id", sessionId);
        params.put("business_type", businessType);
        params.put("sendJson", sendJson);
        String response = HttpClientUtil.postBody(imAddr, params);
        return response;
    }
    /**
     * 更新会话状态
     *

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java

@ -44,6 +44,8 @@ public class BaseController {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            logger.info("json:"+json.toString());
            System.out.println("json:"+json.toString());
            return json.getString("uid");
        } catch (Exception e) {

+ 7 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -108,7 +108,8 @@ public class LoginController extends BaseController {
    public String doctor(@ApiParam(required = false, name = "mobile", value = "手机号") @RequestParam(required = false, value = "mobile") String mobile,
                         @ApiParam(required = false, name = "captcha", value = "短信验证码") @RequestParam(required = false) String captcha,
                         @ApiParam(required = false, name = "platform", value = "医生端pc,取药系统 或者对外系统") @RequestParam(required = false) Integer platform,
                         @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password) {
                         @ApiParam(required = false, name = "password", value = "密码") @RequestParam(required = false) String password,
                         @ApiParam(required = false, name = "password", value = "openid") @RequestParam(required = false) String openid) {
        String errorMessage;
        LoginLog loginLog = new LoginLog();
        loginLog.setCreateTime(new Date());
@ -170,6 +171,11 @@ public class LoginController extends BaseController {
                        return error(-1, errorMessage);
                    }
                    loginLogService.saveLog(loginLog);
                    if(StringUtils.isNotBlank(openid)){
                        doctor.setOpenid(openid);
                    }
                    return write(200, "登录成功", "data", map);
                } else {
                    errorMessage = "密码错误,登录失败";

+ 77 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java

@ -174,6 +174,7 @@ public class imController extends BaseController {
                }
                map.put("id", id);
                map.put("status", status);
                map.put("session_id", session_id);
                map.put("photo", avatar);
                map.put("patientName", name);
@ -194,6 +195,39 @@ public class imController extends BaseController {
        }
    }
    /**
     * 获取列表
     * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
     * 第一次列表为当前医生(很可能团队长)待回复列表 传参:doctor有后台获取 status=0,reply=0未回复
     * 后 取团队内单个医生的咨询情况 doctor、status、reply均有前端传入
     *
     * @return
     */
    @RequestMapping(value = "/consult/getListCount", method = RequestMethod.GET)
    @ResponseBody
    public String getConsultCountByStatus(
            @RequestParam(required = false) String doctor,
            @RequestParam Integer status,
            @RequestParam(required = false) Integer reply,
            @ApiParam(name = "type", value = "咨询类型") @RequestParam(required = true) Integer type,
            @ApiParam(name = "patientName", value = "居民姓名") @RequestParam(required = false) String patientName,
            @ApiParam(name = "startTime", value = "开始时间") @RequestParam(required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间") @RequestParam(required = false) String endTime) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                doctor = getUID();
            }
            String consult = null;
            consult = ImUtill.getConsultCountByStatusAndType(doctor, status, reply,type,patientName,startTime,endTime);
            JSONObject json = new JSONObject(consult);
            return write(200, "查询成功", "total", json.getInt("count"));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    /**
     * 获取团队统计数据
     * status = 10 已结束的咨询,status=0,reply = 1 已回复 ,status=0,reply=0未回复
@ -303,6 +337,49 @@ public class imController extends BaseController {
        }
    }
    @RequestMapping(value = "/testwx", method = RequestMethod.POST)
    @ResponseBody
    public String testwx(@ApiParam(name="doctor",value="医生code",defaultValue = "xy201703150222")
                         @RequestParam(value="doctor",required = true) String doctor){
        try {
            Doctor d = doctorDao.findByCode(doctor);
            String sessionId = "ec7572875d27446cb4f067b13a85d72a_0ee64daec62746279517ca70d307a52f_8";
            JSONObject json = new JSONObject();
            json.put("openid", "o7NFZwyjo7Wvhv2Wh0eOUoUtlUT4");
            json.put("template_id", "-dr4QNyFoRvVsf8uWxXMC1dRyjwnbUuJwJ21vBLhf18");
            json.put("url", "wap.baidu.com");
            JSONObject data = new JSONObject();
            JSONObject first = new JSONObject();
            first.put("value","first");
            first.put("color","#000000");
            JSONObject remark = new JSONObject();
            remark.put("value","");
            remark.put("color","#000000");
            JSONObject keyword1 = new JSONObject();
            keyword1.put("value","description");
            keyword1.put("color","#000000");
            JSONObject keyword2 = new JSONObject();
            keyword2.put("value","replyContent");
            keyword2.put("color","#000000");
            JSONObject keyword3 = new JSONObject();
            keyword3.put("value","senderName");
            keyword3.put("color","#000000");
            data.put("first",first);
            data.put("remark",remark);
            data.put("keyword1",keyword1);
            data.put("keyword2",keyword2);
            data.put("keyword3",keyword3);
            json.put("data",data);
            ImUtill.sendDoctorImMsg(doctor, d.getName(), sessionId, "1", "test", "REMAIN",json.toString());
            return success("发送成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "发送失败!");
        }
    }
    public List getMemberByDoctor(String doctor) {
        String sql = "SELECT d.photo,d.`name`,d.sex,d.`code`,d.level " +

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

@ -1116,7 +1116,7 @@ public class DoctorConsultController extends WeixinBaseController {
            String prescriptionCode = consult1.getRelationCode();
            Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
            json.put("status",prescription.getStatus());//状态 (-1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成)
//            json.put("prescriptionDt",prescriptionDiagnosisService.getPrescriptionDiagnosis(prescriptionCode));//续方疾病类型
            json.put("prescriptionDt",prescriptionDiagnosisService.getPrescriptionDiagnosis(prescriptionCode));//续方疾病类型
            json.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(prescriptionCode));//续方药品信息
            //服务类型

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

@ -12,10 +12,10 @@ import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import io.swagger.annotations.Api;
@ -32,10 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@ -45,6 +42,7 @@ import java.util.*;
 * @author George
 */
@Controller
@RestController
@RequestMapping(value = "/doctor/health/edu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "健康教育")
public class DoctorHealthEduArticleController extends WeixinBaseController {
@ -497,7 +495,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    }
    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize, false, "");
        for (Object o : result) {
            JSONObject json = (JSONObject) o;
            String patient = (String) json.get("code");
@ -600,7 +598,136 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    }
    public static void main(String arg[]) {
        System.out.println(MessageType.MESSAGE_TYPE_PATIENT_HEALTH_EDU.P_HE_01.name());
    /**********************************福州健康文章接口********************************************/
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    @RequestMapping(value = "getDoctorArticalList",method = RequestMethod.GET)
    @ApiOperation("获取健康教育文章列表")
    public String getDoctorArticalList(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true,defaultValue = "1") Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            String response = healthEducationArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID());
//            String response = healthEducationArticleService.getDoctorArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getCategoryList",method = RequestMethod.GET)
    @ApiOperation("获取文章类别")
    public String getCategoryList(@ApiParam(name = "categoryLevel", value = "获取类别:1、一级类别 2、二级类别",defaultValue = "1")
                                       @RequestParam(value = "categoryLevel", required = true) String categoryLevel){
        try {
            String response = healthEducationArticleService.getCategoryList(categoryLevel);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getCollectionArticalList",method = RequestMethod.GET)
    @ApiOperation("获取收藏文章列表")
    public String getCollectionArticalList(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true,defaultValue = "1") Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            String response = healthEducationArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID(),1);
//            String response = healthEducationArticleService.getCollectionArticalList(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56",1);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getArticalById",method = RequestMethod.GET)
    @ApiOperation("获取文章详情")
    public String getArticalById(@ApiParam(name = "articleId", value = "文章id",defaultValue = "1")
                                  @RequestParam(value = "articleId", required = true) String articleId){
        try {
            String response = healthEducationArticleService.getArticalById(articleId);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "cancelArticleCollection",method = RequestMethod.POST)
    @ApiOperation("取消收藏文章")
    @ObserverRequired
    public String cancelArticleCollection(@ApiParam(name = "articleId", value = "文章id",defaultValue = "1")
                                 @RequestParam(value = "articleId", required = true) String articleId){
        try {
//            String response = healthEducationArticleService.cancelArticleCollection(articleId,getUID(),1);
            String response = healthEducationArticleService.cancelArticleCollection(articleId,"0de7295862dd11e69faffa163e8aee56",1);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "saveArticleCollection",method = RequestMethod.POST)
    @ApiOperation("收藏文章")
    @ObserverRequired
    public String saveArticleCollection(@ApiParam(name = "articleId", value = "文章id")
                                        @RequestParam(value = "articleId", required = true) String articleId,
                                        @ApiParam(name = "articleCategoryId", value = "文章类别ID")
                                        @RequestParam(value = "articleCategoryId", required = true,defaultValue = "1") String articleCategoryId,
                                        @ApiParam(name = "articleCategoryName", value = "文章类别名称")
                                        @RequestParam(value = "articleCategoryName", required = true) String articleCategoryName){
        try {
//            String response = healthEducationArticleService.saveArticleCollection(articleId,articleCategoryId,articleCategoryName,getUID(),1);
            String response = healthEducationArticleService.saveArticleCollection(articleId,articleCategoryId,articleCategoryName,"0de7295862dd11e69faffa163e8aee56",1);
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "getDoctorArticalByUserId",method = RequestMethod.GET)
    @ApiOperation("获取医生发表的文章列表")
    public String getDoctorArticalByUserId(@ApiParam(name = "articleTitle", value = "文章标题")
                                       @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                       @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                       @RequestParam(value = "articleState", required = true,defaultValue = "1") Integer articleState,
                                       @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                       @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                       @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                       @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
//            String response = healthEducationArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,getUID());
            String response = healthEducationArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
}

+ 64 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
@ -15,6 +16,7 @@ import com.yihu.wlyy.util.DateUtil;
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.json.JSONArray;
import org.json.JSONObject;
@ -25,6 +27,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import java.text.DateFormat;
@ -75,4 +78,65 @@ public class PatientInfoController extends BaseController {
            return invalidUserException(e, -1, "获取患者信息失败!");
        }
    }
    @RequestMapping(value = "createProfile",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("档案建立")
    @ObserverRequired
    public String createProfile(@ApiParam(value = "医生code", name = "doctorCode") @RequestParam(required = true)String doctorCode ,
                                @ApiParam(value = "患者code", name = "patient") @RequestParam(required = true)String patient,
                                @ApiParam(value = "生日(yyyy-MM-dd)", name = "brithday") @RequestParam(required = true)String brithday,
                                @ApiParam(value = "居委会", name = "jwCountryCode") @RequestParam(required = true)String jwCountryCode,
                                @ApiParam(value = "民族", name = "nation") @RequestParam(required = true)String nation,
                                @ApiParam(value = "血型", name = "blood") @RequestParam(required = true)String blood,
                                @ApiParam(value = "婚姻状况", name = "marry") @RequestParam(required = true)String marry,
                                @ApiParam(value = "详细地址", name = "adress") @RequestParam(required = true)String adress){
        try {
            // 获取医生下的患者
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient,brithday, jwCountryCode, nation, blood, marry,adress));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取患者信息失败!");
        }
    }
    @RequestMapping(value = "getNationDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取民族信息列表")
    public String getNationDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getNationDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getMarryDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("婚姻状态字典")
    public String getMarryDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getMarryDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getBloodDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("血型状态字典")
    public String getBloodDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getBloodDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
}

+ 80 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -148,7 +148,9 @@ public class SignPatientLabelInfoController extends BaseController {
                                        @RequestParam(required = false) String labelType,
                                        @RequestParam(required = false) Long teamCode,
                                        @RequestParam(required = false) int page,
                                        @RequestParam(required = false) int pagesize) {
                                        @RequestParam(required = false) int pagesize,
                                        @RequestParam(required = false) String diseaseCondition,
                                        @RequestParam(required = false) boolean isSlowDisease) {
        try {
            if (StringUtils.isEmpty(labelCode)) {
                return error(-1, "标签cdoe不能为空");
@ -162,12 +164,14 @@ public class SignPatientLabelInfoController extends BaseController {
            page = page - 1;
            //按照签约年度  labelCode 是年度 例如 2016
            //labelType=9 签约过期的居民列表
            if (labelType.equals("9")) {
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode, teamCode, getUID(), page, pagesize);
                return write(200, "查询成功", "data", jsonObject);
            }
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize,isSlowDisease,diseaseCondition);
            //JSONArray result = labelInfoService.getPatientByLabel("xh1D201703150222", labelCode, labelType, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
@ -223,7 +227,10 @@ public class SignPatientLabelInfoController extends BaseController {
    public String getTeamPatient(@RequestParam(required = true) Long teamCode,
                                 @RequestParam(required = false) String labelCode,
                                 @RequestParam(required = false) String labelType,
                                 @RequestParam(required = true) int page, @RequestParam(required = true) int pagesize) {
                                 @RequestParam(required = true) int page,
                                 @RequestParam(required = true) int pagesize,
                                 @RequestParam(required = false) String diseaseCondition,
                                 @RequestParam(required = false) boolean isSlowDisease) {
        try {
            if (teamCode == null || teamCode < 1) {
                return error(-1, "团队cdoe不能为空");
@ -235,13 +242,14 @@ public class SignPatientLabelInfoController extends BaseController {
            page = page > 0 ? page - 1 : 0;
            //labelType=9 签约过期的居民列表
            if ("9".equals(labelType)) {
                JSONObject jsonObject = signWebService.getOverDuePatientsByTeam(labelCode, teamCode, page, pagesize);
                return write(200, "查询成功", "data", jsonObject);
            }
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize);
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize,isSlowDisease,diseaseCondition);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -271,11 +279,15 @@ public class SignPatientLabelInfoController extends BaseController {
     *
     * @param labelType 标签类型
     * @param teamCode  团队code
     * @param isSlowDisease 是否是慢病管理
     * @return
     */
    @RequestMapping(value = "/label_patient_amount")
    @ApiOperation("查询某个团队的某个标签类型下各标签患者数")
    public String getPatientAmountByLabelType(@RequestParam(required = false) String labelType, @RequestParam(required = false) Long teamCode) {
    public String getPatientAmountByLabelType(
            @RequestParam(required = false) String labelType,
            @RequestParam(required = false) Long teamCode,
            @RequestParam(required = false) boolean isSlowDisease) {
        try {
            if (StringUtils.isEmpty(labelType)) {
                return error(-1, "标签类型不能为空");
@ -292,7 +304,7 @@ public class SignPatientLabelInfoController extends BaseController {
            }
            if (labelType.equals("1") && teamCode != 0L) {
                JSONArray r = patientService.getSignByDoctorCodeGpbyServer(getUID(), teamCode + "");
                JSONArray r = patientService.getSignByDoctorCodeGpbyServer(getUID(), teamCode + "",isSlowDisease);
                //JSONArray r= patientService.getSignByDoctorCodeGpbyServer("xh1D201703150222",teamCode+"");
                return write(200, "查询成功", "data", r);
            }
@ -459,7 +471,8 @@ public class SignPatientLabelInfoController extends BaseController {
                                             @RequestParam(required = false) Long teamCode,
                                             @RequestParam(required = false) String exLabelCode,
                                             @RequestParam(required = false) String exLabelType,
                                             @RequestParam(required = true) int page, @RequestParam(required = true) int pagesize) {
                                             @RequestParam(required = true) int page,
                                             @RequestParam(required = true) int pagesize) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "搜索字段不能为空");
@ -756,4 +769,64 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/slowdisease/patient/search")
    @ApiOperation("慢病管理:查询某个患者的某类标签根据团队和当前医生")
    public String searchSlowDiseasePatientByNameOrLabel(@RequestParam(required = true) String filter,
                                             @RequestParam(required = false) String labelCode,
                                             @RequestParam(required = false) String labelType,
                                             @RequestParam(required = false) Long teamCode,
                                             @RequestParam(required = false) String exLabelCode,
                                             @RequestParam(required = false) String exLabelType,
                                             @RequestParam(required = true) int page,
                                             @RequestParam(required = true) int pagesize,
                                             @RequestParam(required = false) String diseaseCondition) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "搜索字段不能为空");
            }
            if (!StringUtils.isEmpty(labelCode) && StringUtils.isEmpty(labelType)) {
                return error(-1, "标签参数不为空时标签类型不能为空");
            }
            if (!StringUtils.isEmpty(exLabelCode) && StringUtils.isEmpty(exLabelType)) {
                return error(-1, "过滤标签参数不为空时过滤标签类型不能为空");
            }
            if (teamCode == null) {
                teamCode = 0L;
            }
            page = page - 1;
            JSONArray result = labelInfoService.searchSlowDiseasePatientByNameOrLabel(getUID(), filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize,diseaseCondition);
            //JSONArray result = labelInfoService.searchPatientByNameOrLabel("test00000000005", filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/slowdisease/search/patient/allexitdoc", method = RequestMethod.GET)
    @ApiOperation("慢病管理:根据姓名搜索所有团队下居民(根据团队)")
    public String searchSlowDiseasePatientsExitDoc(@RequestParam(required = true) String filter,
                                        @RequestParam(required = true, defaultValue = "0") long teamCode,
                                        @RequestParam(required = false, defaultValue = "0") int page,
                                        @RequestParam(required = false, defaultValue = "15") int pagesize,
                                        @RequestParam(required = false) String diseaseCondition) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "查询参数不能为空");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray result = labelInfoService.searchSlowDiseaseTeamsPatients(filter, teamCode, page, pagesize,diseaseCondition);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -66,7 +66,7 @@ public class PrescriptionInfoController extends BaseController {
    @ApiOperation(value = "获取全科医生/建管师续方列表/搜索")
    public String getDoctorPrescription(@RequestParam(required = false) @ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false) @ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = false) @ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = false) @ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "diseases") String diseases,
                                        @RequestParam(required = false) @ApiParam(name = "startDate", value = "开始时间") String startDate,
                                        @RequestParam(required = false) @ApiParam(name = "endDate", value = "结束时间") String endDate,
                                        @RequestParam(required = false) @ApiParam(name = "nameKeyword", value = "患者姓名模糊匹配") String nameKeyword,
@ -267,7 +267,7 @@ public class PrescriptionInfoController extends BaseController {
             @RequestParam(required = false) @ApiParam(value = "服务站", name = "hospital") String hospital,
             @RequestParam(required = false) @ApiParam(value = "配送状态", name = "state") String state) {
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getHDoctorPrescriptionExpressageTotal(teamCode, type, getRepUID(), nameKey, startDate, endDate, hospital, state));
            return write(200, "操作成功!", "data", prescriptionInfoService.getHDoctorPrescriptionExpressageTotal(teamCode, type, getUID(), nameKey, startDate, endDate, hospital, state));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");

+ 116 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java

@ -0,0 +1,116 @@
package com.yihu.wlyy.web.doctor.scheme;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.wlyy.service.app.scheme.DoctorSchemeService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * 医生端-监测方案相关接口
 * @author huangwenjie
 * @date 2017/9/13 15:39
 */
@RestController
@RequestMapping(value = "/doctor/scheme/")
@Api(description = "医生端-监测方案相关接口")
public class DoctroSchemeController extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(DoctroSchemeController.class);
    @Autowired
    private DoctorSchemeService doctorSchemeService;
    @RequestMapping(value="/get/disease/patientcodes",method = RequestMethod.GET)
    @ApiOperation("医生端-根据居民标签/病情/设备绑定状态查询团队居民CODE列表")
    public String getDiseasePatientCodes (
            @ApiParam(name="teamCode", value="团队CODE") @RequestParam(value = "teamCode",required = true) String teamCode,
            @ApiParam(name="disease", value="疾病类型,-1全部,0健康,1高血压,2糖尿病,3高血压+糖尿病") @RequestParam(value = "disease",required = true) Integer disease,
            @ApiParam(name="diseaseCondition", value="居民标签:-1全部,0绿标,1黄标,2红标") @RequestParam(value = "diseaseCondition",required = true) Integer diseaseCondition,
            @ApiParam(name="deviceType", value="设备类型:-1全部,0未绑定,1已绑定") @RequestParam(value = "deviceType",required = true) Integer deviceType
            ){
        try {
            List<String> result = doctorSchemeService.getPatientsByDiseaseConditionDiseaseDeviceType(teamCode,disease,diseaseCondition,deviceType);
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败,"+e.getMessage());
        }
    }
    @RequestMapping(value="/get/bloodsugger/list",method = RequestMethod.GET)
    @ApiOperation("医生获取自己的血糖监测方案列表")
    public String getDoctorSchemeBloodSuggerList(
            @ApiParam(name="doctorcode", value="医生CODE") @RequestParam(value = "doctorcode",required = true) String doctorcode){
        try {
            List<DoctorSchemeBloodSuggerVO> result = doctorSchemeService.getDoctorScheBloodSuggerList(doctorcode);
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败,"+e.getMessage());
        }
    }
    @RequestMapping(value="/get/bloodpressure/list",method = RequestMethod.GET)
    @ApiOperation("医生获取自己的血压监测方案列表")
    public String getDoctorSchemeBloodPressureList(
            @ApiParam(name="doctorcode", value="医生CODE") @RequestParam(value = "doctorcode",required = true) String doctorcode){
        try {
            List<DoctorSchemeBloodPressureVO> result = doctorSchemeService.getDoctorSchemeBloodPressureList(doctorcode);
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败,"+e.getMessage());
        }
    }
    @RequestMapping(value="/post/save/patient/bloodpressure",method = RequestMethod.POST)
    @ApiOperation("医生保存居民的血压监测方案")
    public String saveDoctorSchemeBloodPressure(
            @ApiParam(name="data", value="JSON数据") @RequestParam(value = "data",required = true) String data){
        try {
            doctorSchemeService.saveDoctorSchemeBloodPressure(data);
            return write(200, "操作成功");
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败,"+e.getMessage());
        }
    }
    @RequestMapping(value="/post/save/patient/bloodsugger",method = RequestMethod.POST)
    @ApiOperation("医生保存居民的血糖监测方案")
    public String saveDoctorSchemeBloodSugger(
            @ApiParam(name="data", value="JSON数据") @RequestParam(value = "data",required = true) String data){
        try {
            doctorSchemeService.saveDoctorSchemeBloodSugger(data);
            return write(200, "操作成功");
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败,"+e.getMessage());
        }
    }
}

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

@ -669,7 +669,7 @@ public class DoctorSignController extends WeixinBaseController {
    @ResponseBody
    public String getSignByDoctorCodeGpbyServer(){
        try {
            JSONArray result = patientService.getSignByDoctorCodeGpbyServer(getUID(),null);
            JSONArray result = patientService.getSignByDoctorCodeGpbyServer(getUID(),null, false);
            //JSONArray result = patientService.getSignByDoctorCodeGpbyServer("xh1D201703150222");
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {

+ 69 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorFeldsherTemplateController.java

@ -0,0 +1,69 @@
package com.yihu.wlyy.web.doctor.template;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.template.DoctorFeldsherTemplateService;
import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
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.json.JSONArray;
import org.json.JSONObject;
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;
import java.util.Map;
/**
 * 医生健康指导模板
 * <p>
 * Created by Reece on 2017/9/14.
 */
@RestController
@RequestMapping(value = "/doctor/feldsher")
@Api(description = "医生健康指导模板")
public class DoctorFeldsherTemplateController extends BaseController {
    @Autowired
    private DoctorFeldsherTemplateService feldsherTemplateService;
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    /**
     * @param doctorCode   医生code
     * @param sessionId    会话Id
     * @param sessionType  会话类型
     * @param businessType 消息类型
     * @param from         发送者
     * @param content      消息内容
     * @return
     */
    @RequestMapping(value = "/sendDoctorTemplate", method = RequestMethod.GET)
    @ApiOperation(value = "医生助手给医生发送模板消息")
    public String sendDoctorTemplate(@RequestParam @ApiParam(value = "医生code") String doctorCode,
                                     @RequestParam @ApiParam(value = "会话Id", required = false) String sessionId,
                                     @RequestParam @ApiParam(value = "会话类型", required = false) String sessionType,
                                     @RequestParam @ApiParam(value = "消息类型") String businessType,
                                     @RequestParam @ApiParam(value = "发送者", required = false) String from,
                                     @RequestParam @ApiParam(value = "消息内容") String content) {
        try {
            Boolean flag = feldsherTemplateService.sendDoctorTemplate(doctorCode, sessionId, sessionType, businessType, from, content);
            if (flag){
                return write(200, "发送成功!");
            }else {
                return write( -1, "发送失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}

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

@ -385,7 +385,7 @@ public class PatientHealthController extends BaseController {
                                        @RequestParam(value = "data", required = true) String data,
                                        @ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                        @RequestParam(value = "type", required = true) String type,
                                        @ApiParam(name = "patient", value = "居民code", defaultValue = "1")
                                        @ApiParam(name = "patient", value = "patient", defaultValue = "1")
                                        @RequestParam(value = "patient", required = false) String patient) {
        try {
//            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
@ -450,7 +450,7 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("患者获取健康指标")
    public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
    public String getHealthIndexByPatient(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重/身高,4腰围)", defaultValue = "1")
                                          @RequestParam(value = "type", required = true) int type,
                                          @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
                                          @RequestParam(value = "start", required = true) String start,

+ 6 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -57,7 +57,6 @@ public class FamilyContractController extends BaseController {
    private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
    @Autowired
    private SignWebService signWebService;
    /**
     * 得到患者的签约的医生的信息
     *
@ -395,6 +394,12 @@ public class FamilyContractController extends BaseController {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
            }
            //===1.3.7 加入建档判断
            String flag = familyContractService.getSickArchiveFlag(patient);
            if("0".equals(flag)){
               return error(-2, "用户未建档");
            }
            //==1.3.7===end===
            int result = familyContractService.sign(doctor,patient,countryCode);

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java

@ -20,6 +20,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -47,7 +49,7 @@ public class GcDoctorController extends BaseController {
    @Autowired
    private FamilyContractService familyContractService;
    private Logger logger = LoggerFactory.getLogger(GcDoctorController.class);
    @RequestMapping(value = "/doctor", method = RequestMethod.GET)
    @ApiOperation("根据医生code查询医生信息")
    public ResultOneModel<DoctorModel> doctor(
@ -106,7 +108,9 @@ public class GcDoctorController extends BaseController {
    @ApiOperation("获取医生所属团队")
    public ResultListModel<AdminTeamModel> doctors(
    ) {
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());
        logger.info("getUID:"+getUID());
        System.out.println("getUID:"+getUID());
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());//hxmD201703150222"
        List<AdminTeamModel> adminTeamModelList = new ArrayList<>();
        if (teams != null && teams.size() > 0) {
            teams.stream().forEach(one -> {

+ 3 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -1,13 +1,11 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.third.gateway.service.GcLabelService;
import com.yihu.wlyy.web.third.gateway.vo.DictModel;
import com.yihu.wlyy.web.third.gateway.vo.HospitalModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientLabelModel;
import com.yihu.wlyy.web.third.gateway.vo.PatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
@ -18,7 +16,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -98,10 +95,11 @@ public class GcLableController extends BaseController {
            @ApiParam(name = "labelCode", value = "标签code", required = true) @RequestParam(value = "labelCode", required = true) String labelCode,
            @ApiParam(name = "teamCode", value = "所属团队", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode,
            @ApiParam(name = "page", value = "当前页(1开始)", required = true) @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize
            @ApiParam(name = "pageSize", value = "每页大小", required = true) @RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize,
            @ApiParam(name = "isSlowDisease", value = "是否是慢病管理", required = true) @RequestParam(value="isSlowDisease",required = false,defaultValue = "false") boolean isSlowDisease
    ) {
        try {
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize);
            JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page-1, pageSize, isSlowDisease, "");
            List<PatientModel> patientLabelModels = new ArrayList<>();
            for (int i = 0; i < result.length(); i++) {
                JSONObject jo = result.getJSONObject(i);

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -183,7 +183,7 @@ public class GcEduArticleService {
        }
        //保存到ES中
        //elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        return healthEduArticlePatients;
    }

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -4,12 +4,13 @@ import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
@ -69,7 +70,7 @@ public class OnePayController extends WeixinBaseController {
    @Autowired
    LogService logService;
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
@ -262,6 +263,7 @@ public class OnePayController extends WeixinBaseController {
     */
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
@ -347,6 +349,7 @@ public class OnePayController extends WeixinBaseController {
     */
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";

+ 1 - 7
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -13,7 +13,7 @@ spring:
      password: 123456
  redis:
    host: 172.19.103.47 # Redis server host.
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
@ -82,12 +82,6 @@ images:
sign:
  check_upload: http://172.19.103.87:8011/wlyy_service
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
express:
  sf_url: http://218.17.248.244:11080/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic

+ 0 - 8
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -78,14 +78,6 @@ images:
sign:
  check_upload: http://59.61.92.90:8072/wlyy_service
ylzpay:
#  onepayApi: https://xmhealth.ylzpay.com:8080/
  onepayApi: http://xmhealth.ylzpay.com:8070/
  onepayAppId: 1BLF5SEGN00087165F0A000027362BE5
  onepayAppSecret: 1BLF5SCBO01V3E78A8C00000F3A0FFE7
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService

+ 0 - 6
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -77,12 +77,6 @@ images:
sign:
  check_upload: http://172.19.103.88:8011/wlyy_service
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
express:
  sf_url: http://218.17.248.244:11080/bsp-oisp/sfexpressService
#  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

@ -61,7 +61,7 @@
	  "sub_button":[
		{
		   "type":"view",
		   "name":"专属服务",
		   "name":"签约特色服务",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fdist%2fhtml%2fexclusive-service.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
		{