Explorar el Código

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

chenweida hace 8 años
padre
commit
f70ec6c1b0
Se han modificado 41 ficheros con 3304 adiciones y 283 borrados
  1. 246 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/charge/WlyyCharge.java
  2. 85 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/SignLabel.java
  3. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientFamilyMember.java
  4. 135 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlan.java
  5. 107 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlanLibrary.java
  6. 442 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPreCard.java
  7. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  8. 30 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/job/PrenatalInspectorJob.java
  9. 20 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java
  10. 17 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SignLabelDao.java
  11. 20 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java
  12. 20 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanLibraryDao.java
  13. 17 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPreCardDao.java
  14. 84 16
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  15. 243 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  16. 240 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  17. 20 20
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  18. 642 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  19. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java
  20. 5 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java
  21. 21 28
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/model/Charge.java
  22. 244 28
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  23. 19 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  24. 30 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  25. 27 11
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java
  26. 5 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemConf.java
  27. 24 14
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  28. 12 16
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  29. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  30. 13 15
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  31. 8 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java
  32. 57 39
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  33. 19 15
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultPublicController.java
  34. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  35. 60 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  36. 19 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthController.java
  37. 28 22
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthRecordController.java
  38. 78 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/PrenatalInspectorContoller.java
  39. 76 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  40. 161 9
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java
  41. 5 0
      patient-co-wlyy/src/main/resources/system.properties

+ 246 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/charge/WlyyCharge.java

@ -0,0 +1,246 @@
package com.yihu.wlyy.entity.charge;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 扣费记录
 * @author hzp
 */
@Entity
@Table(name = "wlyy_charge")
public class WlyyCharge extends IdEntity {
	private String code;   //  接入应用支付业务流水号
	private String chargeType;   //交易类型  1签约 2续签
	private String chargeRelation;   //交易关联代码
	private Date createTime;   //  接入应用内支付时间
	private String patient;   //  用户
	private String openid;   //  用戶微信openid
	private String ssc;   // 医保卡号
	private String name;   //  姓名
	private String idType;   //  证件类型
	private String idNo;   //  证件号码
	private String hospital;   //  机构代码
	private String hospitalName;   //  机构名称
	private Integer totalAmount;   //  交易总金额
	private Integer selfpayAmount;   //  自费金额
	private Integer insuranceAmount;   //  医保支付金额
	private String feeDetail;   //  费用明细
	private String channel;   //  医保支付渠道
	private String merchName;   //  收款单位名称
	private String subject;   //  订单名称
	private String tradeStatus;   //  交易状态0 成功 1 失败 2 已退款
	private String chargeNo;   //  流水号
	private String chargeTime;   // 扣费时间YYYYMMDDHHMMSS
	private String medOrgNo;   //  医疗机构编码
	private String medOrgName;   //  医疗机构名称
	private String billNo;   //  待结算费用单据号
	public String getChargeType() {
		return chargeType;
	}
	public void setChargeType(String chargeType) {
		this.chargeType = chargeType;
	}
	public String getChargeRelation() {
		return chargeRelation;
	}
	public void setChargeRelation(String chargeRelation) {
		this.chargeRelation = chargeRelation;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public String getSsc() {
		return ssc;
	}
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getIdType() {
		return idType;
	}
	public void setIdType(String idType) {
		this.idType = idType;
	}
	public String getIdNo() {
		return idNo;
	}
	public void setIdNo(String idNo) {
		this.idNo = idNo;
	}
	public String getHospital() {
		return hospital;
	}
	public void setHospital(String hospital) {
		this.hospital = hospital;
	}
	public String getHospitalName() {
		return hospitalName;
	}
	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}
	public Integer getTotalAmount() {
		return totalAmount;
	}
	public void setTotalAmount(Integer totalAmount) {
		this.totalAmount = totalAmount;
	}
	public Integer getSelfpayAmount() {
		return selfpayAmount;
	}
	public void setSelfpayAmount(Integer selfpayAmount) {
		this.selfpayAmount = selfpayAmount;
	}
	public Integer getInsuranceAmount() {
		return insuranceAmount;
	}
	public void setInsuranceAmount(Integer insuranceAmount) {
		this.insuranceAmount = insuranceAmount;
	}
	public String getFeeDetail() {
		return feeDetail;
	}
	public void setFeeDetail(String feeDetail) {
		this.feeDetail = feeDetail;
	}
	public String getChannel() {
		return channel;
	}
	public void setChannel(String channel) {
		this.channel = channel;
	}
	public String getMerchName() {
		return merchName;
	}
	public void setMerchName(String merchName) {
		this.merchName = merchName;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public String getTradeStatus() {
		return tradeStatus;
	}
	public void setTradeStatus(String tradeStatus) {
		this.tradeStatus = tradeStatus;
	}
	public String getChargeNo() {
		return chargeNo;
	}
	public void setChargeNo(String chargeNo) {
		this.chargeNo = chargeNo;
	}
	public String getChargeTime() {
		return chargeTime;
	}
	public void setChargeTime(String chargeTime) {
		this.chargeTime = chargeTime;
	}
	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 String getBillNo() {
		return billNo;
	}
	public void setBillNo(String billNo) {
		this.billNo = billNo;
	}
}

+ 85 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/doctor/team/sign/SignLabel.java

@ -0,0 +1,85 @@
package com.yihu.wlyy.entity.doctor.team.sign;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2017/6/1.
 */
@Entity
@Table(name = "wlyy_sign_label")
public class SignLabel extends IdEntity {
    // 标签code
    private String label;
    // 标签名称
    private String name;
    // 是否系统标签
    private Integer isSystem;
    // 图标
    private String imgUrl;
    // 排序
    private Integer sort;
    // 状态 0:无效 1:有效
    private Integer status;
    // 操作日期
    private Date czrq;
    public String getLabel() {
        return label;
    }
    public void setLabel(String label) {
        this.label = label;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getIsSystem() {
        return isSystem;
    }
    public void setIsSystem(Integer isSystem) {
        this.isSystem = isSystem;
    }
    public String getImgUrl() {
        return imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

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

@ -20,6 +20,8 @@ public class PatientFamilyMember extends IdEntity {
    private String familyMember;
    // 家庭关系
    private Integer familyRelation;
    //是否授权0:未授权,1:已授权,默认为1
    private Integer isAuthorize;
    // 操作日期
    private Date czrq;
@ -44,6 +46,14 @@ public class PatientFamilyMember extends IdEntity {
        this.familyRelation = familyRelation;
    }
    public Integer getIsAuthorize() {
        return isAuthorize;
    }
    public void setIsAuthorize(Integer isAuthorize) {
        this.isAuthorize = isAuthorize;
    }
    public Date getCzrq() {
        return czrq;
    }

+ 135 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlan.java

@ -0,0 +1,135 @@
package com.yihu.wlyy.entity.patient.prenatal;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 产检计划
 * Created by yeshijie on 2017/6/6.
 */
@Entity
@Table(name = "wlyy_prenatal_inspector_plan")
public class PrenatalInspectorPlan extends IdEntity implements Serializable {
    private String inspectionCode;//产检code
    private String patient;//居民code
    private String name;//名称
    private Date inspectionTime;//产检时间
    private Date inspectionStartTime;//产检开始时间(系统计算)
    private Date inspectionEndTime;//产检结束时间(系统计算)
    private String thisFocus;//本次重点
    private String checkItem;//检查项目
    private String thisNote;//本次注意
    private String status;//产检状态(0未产检,1已产检)
    private String inspectionPhase;//检查阶段(1社区检查,2医院检查)
    private String signHospital;//签约医院code(已签约且社区检查阶段才有值)
    private Date czrq;//创建日期
    public String getInspectionCode() {
        return inspectionCode;
    }
    public void setInspectionCode(String inspectionCode) {
        this.inspectionCode = inspectionCode;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Date getInspectionTime() {
        return inspectionTime;
    }
    public void setInspectionTime(Date inspectionTime) {
        this.inspectionTime = inspectionTime;
    }
    public Date getInspectionStartTime() {
        return inspectionStartTime;
    }
    public void setInspectionStartTime(Date inspectionStartTime) {
        this.inspectionStartTime = inspectionStartTime;
    }
    public Date getInspectionEndTime() {
        return inspectionEndTime;
    }
    public void setInspectionEndTime(Date inspectionEndTime) {
        this.inspectionEndTime = inspectionEndTime;
    }
    public String getThisFocus() {
        return thisFocus;
    }
    public void setThisFocus(String thisFocus) {
        this.thisFocus = thisFocus;
    }
    public String getCheckItem() {
        return checkItem;
    }
    public void setCheckItem(String checkItem) {
        this.checkItem = checkItem;
    }
    public String getThisNote() {
        return thisNote;
    }
    public void setThisNote(String thisNote) {
        this.thisNote = thisNote;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getInspectionPhase() {
        return inspectionPhase;
    }
    public void setInspectionPhase(String inspectionPhase) {
        this.inspectionPhase = inspectionPhase;
    }
    public String getSignHospital() {
        return signHospital;
    }
    public void setSignHospital(String signHospital) {
        this.signHospital = signHospital;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 107 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlanLibrary.java

@ -0,0 +1,107 @@
package com.yihu.wlyy.entity.patient.prenatal;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * 产检计划库
 * Created by yeshijie on 2017/6/6.
 */
@Entity
@Table(name = "wlyy_prenatal_inspector_plan_library")
public class PrenatalInspectorPlanLibrary extends IdEntity implements Serializable {
    private String name;//名称
    private String thisFocus;//本次重点
    private String checkItem;//检查项目
    private String thisNote;//本次注意
    private String inspectionWeek;//产检孕周
    private String inspectionTimes;//产检次数
    private String inspectionPhase;//检查阶段
    private Long startDay;//开始天数(距怀孕天数)
    private Long endDay;//结束天数(距怀孕天数)
    private String czrq;//创建日期
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getThisFocus() {
        return thisFocus;
    }
    public void setThisFocus(String thisFocus) {
        this.thisFocus = thisFocus;
    }
    public String getCheckItem() {
        return checkItem;
    }
    public void setCheckItem(String checkItem) {
        this.checkItem = checkItem;
    }
    public String getThisNote() {
        return thisNote;
    }
    public void setThisNote(String thisNote) {
        this.thisNote = thisNote;
    }
    public String getInspectionWeek() {
        return inspectionWeek;
    }
    public void setInspectionWeek(String inspectionWeek) {
        this.inspectionWeek = inspectionWeek;
    }
    public String getInspectionTimes() {
        return inspectionTimes;
    }
    public void setInspectionTimes(String inspectionTimes) {
        this.inspectionTimes = inspectionTimes;
    }
    public String getInspectionPhase() {
        return inspectionPhase;
    }
    public void setInspectionPhase(String inspectionPhase) {
        this.inspectionPhase = inspectionPhase;
    }
    public Long getStartDay() {
        return startDay;
    }
    public void setStartDay(Long startDay) {
        this.startDay = startDay;
    }
    public Long getEndDay() {
        return endDay;
    }
    public void setEndDay(Long endDay) {
        this.endDay = endDay;
    }
    public String getCzrq() {
        return czrq;
    }
    public void setCzrq(String czrq) {
        this.czrq = czrq;
    }
}

+ 442 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPreCard.java

@ -0,0 +1,442 @@
package com.yihu.wlyy.entity.patient.prenatal;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 产检预建卡
 * Created by yeshijie on 2017/6/6.
 */
@Entity
@Table(name = "wlyy_prenatal_inspector_pre_card")
public class PrenatalInspectorPreCard extends IdEntity implements Serializable{
    private String code;//产检code
    private String patient;//居民code
    private String name;//居民姓名
    private String ssc;//医保卡号
    private Date birthday;//出生日期
    private String mobile;//手机号码
    private Date lastMenstrualDate;//末次月经时间
    private String allergyHistory;//过敏史
    private String maritalStatus;//婚姻情况(1未婚,2已婚,3再婚,4丧偶,5离婚,6分居)
    private String residentialAddress;//现居住址
    private String residentialProvince;//住址省份
    private String residentialCity;//住址城市
    private String residentialTown;//住址区(县)
    private String permanentAddress;//户籍地址
    private String permanentProvince;//户籍省份
    private String permanentCity;//户籍城市
    private String permanentTown;//户籍区(县)
    private Date marryDate;//结婚日期
    private String spouseName;//配偶姓名
    private Date spouseBirthday;//配偶生日
    private String spouseMobile;//配偶手机
    private String eatFolate;//服用叶酸(1是,0否)
    private String eatAcyeterion;//服避孕药(1是,0否)
    private String smoke;//吸烟(1是,0否)
    private String drink;//饮酒(1是,0否)
    private String eatOtherDrugs;//服用其他药物
    private String workUnit;//工作单位
    private String height;//身高(cm)
    private String weight;//体重(kg)
    private Integer vaginalDeliveryTimes;//阴道分娩次数(次)
    private Integer caesareanSectionTimes;//剖宫产次数(次)
    private Integer menarcheAge;//初潮(岁)
    private Integer menstrualPeriod;//经期(天)
    private Integer menstrualCycle;//周期(天)
    private String diseaseHistory;//疾病史
    private String operationHistory;//手术史
    private String otherInformation;//其他
    private String effective;//是否有效(1有效,0无效)
    private String status;//状态
    private Date dueDate;//预产期
    private String hospital;//医院
    private String hospitalName;//医院名称
    private String bedNo;//床位
    private String orderBedTime;//预约床位时间
    private String inspectionPhase;//检查阶段(1社区检查,2医院检查)
    private String del;//是否删除(1正常,0废弃)
    private Date czrq;//创建日期
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public Date getLastMenstrualDate() {
        return lastMenstrualDate;
    }
    public void setLastMenstrualDate(Date lastMenstrualDate) {
        this.lastMenstrualDate = lastMenstrualDate;
    }
    public String getAllergyHistory() {
        return allergyHistory;
    }
    public void setAllergyHistory(String allergyHistory) {
        this.allergyHistory = allergyHistory;
    }
    public String getMaritalStatus() {
        return maritalStatus;
    }
    public void setMaritalStatus(String maritalStatus) {
        this.maritalStatus = maritalStatus;
    }
    public String getResidentialAddress() {
        return residentialAddress;
    }
    public void setResidentialAddress(String residentialAddress) {
        this.residentialAddress = residentialAddress;
    }
    public String getResidentialProvince() {
        return residentialProvince;
    }
    public void setResidentialProvince(String residentialProvince) {
        this.residentialProvince = residentialProvince;
    }
    public String getResidentialCity() {
        return residentialCity;
    }
    public void setResidentialCity(String residentialCity) {
        this.residentialCity = residentialCity;
    }
    public String getResidentialTown() {
        return residentialTown;
    }
    public void setResidentialTown(String residentialTown) {
        this.residentialTown = residentialTown;
    }
    public String getPermanentAddress() {
        return permanentAddress;
    }
    public void setPermanentAddress(String permanentAddress) {
        this.permanentAddress = permanentAddress;
    }
    public String getPermanentProvince() {
        return permanentProvince;
    }
    public void setPermanentProvince(String permanentProvince) {
        this.permanentProvince = permanentProvince;
    }
    public String getPermanentCity() {
        return permanentCity;
    }
    public void setPermanentCity(String permanentCity) {
        this.permanentCity = permanentCity;
    }
    public String getPermanentTown() {
        return permanentTown;
    }
    public void setPermanentTown(String permanentTown) {
        this.permanentTown = permanentTown;
    }
    public Date getMarryDate() {
        return marryDate;
    }
    public void setMarryDate(Date marryDate) {
        this.marryDate = marryDate;
    }
    public String getSpouseName() {
        return spouseName;
    }
    public void setSpouseName(String spouseName) {
        this.spouseName = spouseName;
    }
    public Date getSpouseBirthday() {
        return spouseBirthday;
    }
    public void setSpouseBirthday(Date spouseBirthday) {
        this.spouseBirthday = spouseBirthday;
    }
    public String getSpouseMobile() {
        return spouseMobile;
    }
    public void setSpouseMobile(String spouseMobile) {
        this.spouseMobile = spouseMobile;
    }
    public String getEatFolate() {
        return eatFolate;
    }
    public void setEatFolate(String eatFolate) {
        this.eatFolate = eatFolate;
    }
    public String getEatAcyeterion() {
        return eatAcyeterion;
    }
    public void setEatAcyeterion(String eatAcyeterion) {
        this.eatAcyeterion = eatAcyeterion;
    }
    public String getSmoke() {
        return smoke;
    }
    public void setSmoke(String smoke) {
        this.smoke = smoke;
    }
    public String getDrink() {
        return drink;
    }
    public void setDrink(String drink) {
        this.drink = drink;
    }
    public String getEatOtherDrugs() {
        return eatOtherDrugs;
    }
    public void setEatOtherDrugs(String eatOtherDrugs) {
        this.eatOtherDrugs = eatOtherDrugs;
    }
    public String getWorkUnit() {
        return workUnit;
    }
    public void setWorkUnit(String workUnit) {
        this.workUnit = workUnit;
    }
    public String getHeight() {
        return height;
    }
    public void setHeight(String height) {
        this.height = height;
    }
    public String getWeight() {
        return weight;
    }
    public void setWeight(String weight) {
        this.weight = weight;
    }
    public Integer getVaginalDeliveryTimes() {
        return vaginalDeliveryTimes;
    }
    public void setVaginalDeliveryTimes(Integer vaginalDeliveryTimes) {
        this.vaginalDeliveryTimes = vaginalDeliveryTimes;
    }
    public Integer getCaesareanSectionTimes() {
        return caesareanSectionTimes;
    }
    public void setCaesareanSectionTimes(Integer caesareanSectionTimes) {
        this.caesareanSectionTimes = caesareanSectionTimes;
    }
    public Integer getMenarcheAge() {
        return menarcheAge;
    }
    public void setMenarcheAge(Integer menarcheAge) {
        this.menarcheAge = menarcheAge;
    }
    public Integer getMenstrualPeriod() {
        return menstrualPeriod;
    }
    public void setMenstrualPeriod(Integer menstrualPeriod) {
        this.menstrualPeriod = menstrualPeriod;
    }
    public Integer getMenstrualCycle() {
        return menstrualCycle;
    }
    public void setMenstrualCycle(Integer menstrualCycle) {
        this.menstrualCycle = menstrualCycle;
    }
    public String getDiseaseHistory() {
        return diseaseHistory;
    }
    public void setDiseaseHistory(String diseaseHistory) {
        this.diseaseHistory = diseaseHistory;
    }
    public String getOperationHistory() {
        return operationHistory;
    }
    public void setOperationHistory(String operationHistory) {
        this.operationHistory = operationHistory;
    }
    public String getOtherInformation() {
        return otherInformation;
    }
    public void setOtherInformation(String otherInformation) {
        this.otherInformation = otherInformation;
    }
    public String getEffective() {
        return effective;
    }
    public void setEffective(String effective) {
        this.effective = effective;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public Date getDueDate() {
        return dueDate;
    }
    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getBedNo() {
        return bedNo;
    }
    public void setBedNo(String bedNo) {
        this.bedNo = bedNo;
    }
    public String getOrderBedTime() {
        return orderBedTime;
    }
    public void setOrderBedTime(String orderBedTime) {
        this.orderBedTime = orderBedTime;
    }
    public String getInspectionPhase() {
        return inspectionPhase;
    }
    public void setInspectionPhase(String inspectionPhase) {
        this.inspectionPhase = inspectionPhase;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.event;
import com.yihu.wlyy.job.PrenatalInspectorJob;
import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.SignAgainJob;
import com.yihu.wlyy.job.SignEndJob;
@ -47,6 +48,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                System.out.println("sign_again_job exist");
            }
            //启动发送产检提醒模板消息
            if (!quartzHelper.isExistJob("prenatal_inspector_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prenatal_inspector_job_trigger");
                quartzHelper.addJob(PrenatalInspectorJob.class, trigger, "prenatal_inspector_job", new HashMap<String, Object>());
                System.out.println("prenatal_inspector_job start success");
            } else {
                System.out.println("prenatal_inspector_job exist");
            }
        } catch (Exception e) {
            System.out.println("sign end job start failed");
        }

+ 30 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/PrenatalInspectorJob.java

@ -0,0 +1,30 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.app.prenatalInspector.PrenatalInspectorPreCardService;
import com.yihu.wlyy.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
/**
 * 产检提醒(1预约提醒,2就诊提醒)
 * Created by yeshijie on 2017/6/7.
 */
public class PrenatalInspectorJob implements Job{
    @Autowired
    private PrenatalInspectorPreCardService preCardService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
        System.out.print("prenatal inspector wx message sending...");
        String date = DateUtil.dateToStrShort(new Date());
        //发送产检微信模板提醒消息
        preCardService.sendPrenatalInspectorRemind();
    }
}

+ 20 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java

@ -0,0 +1,20 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.charge;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>, JpaSpecificationExecutor<WlyyCharge> {
    List<WlyyCharge> findByChargeTypeAndChargeRelation(String chargeType,String chargeRelation);
    List<WlyyCharge> findByPatient(String patient, Pageable pageRequest);
}

+ 17 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SignLabelDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.team.sign.SignLabel;
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 yeshijie on 2017/6/1.
 */
public interface SignLabelDao extends PagingAndSortingRepository<SignLabel, Long>, JpaSpecificationExecutor<SignLabel> {
    @Query("select a from SignLabel a where a.status = 1 order by sort")
    List<SignLabel> findLabels();
}

+ 20 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java

@ -0,0 +1,20 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlanLibrary;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/6/6.
 */
public interface PrenatalInspectorPlanDao extends PagingAndSortingRepository<PrenatalInspectorPlan, Long>{
    @Query("select a from PrenatalInspectorPlan a where a.inspectionCode = ?1 and a.status = '0' ")
    List<PrenatalInspectorPlan> findByCode(String inspectionCode);
    @Query("select a from PrenatalInspectorPlan a where a.inspectionTime is not null and a.status = '0' and ( TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=7 or TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=1 ) ")
    List<PrenatalInspectorPlan> findWxTipList();
}

+ 20 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanLibraryDao.java

@ -0,0 +1,20 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlanLibrary;
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 yeshijie on 2017/6/6.
 */
public interface PrenatalInspectorPlanLibraryDao extends PagingAndSortingRepository<PrenatalInspectorPlanLibrary, Long>{
    @Query("select a from PrenatalInspectorPlanLibrary a where a.endDay >= ?1 ")
    List<PrenatalInspectorPlanLibrary> findByDays(Long endDay);
}

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

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlanLibrary;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPreCard;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/6/6.
 */
public interface PrenatalInspectorPreCardDao extends PagingAndSortingRepository<PrenatalInspectorPreCard, Long>{
    @Query("select a from PrenatalInspectorPreCard a where a.patient = ?1 and a.del='1' order by a.lastMenstrualDate desc")
    List<PrenatalInspectorPreCard> findByPatient(String patient);
}

+ 84 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -15,6 +15,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
@ -22,6 +23,7 @@ import com.yihu.wlyy.repository.consult.ConsultTeamLogDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
@ -49,6 +51,7 @@ import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.*;
@ -84,7 +87,8 @@ public class ConsultTeamService extends ConsultService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientHealthGuidanceService guidanceService;
    @Autowired
    private PatientFamilyMemberDao familyMemberDao;
    @Autowired
    private HealthEduArticleService healthEduArticleService;
@ -96,6 +100,20 @@ public class ConsultTeamService extends ConsultService {
    @Autowired
    WeiXinAccessTokenUtils accessTokenUtils;
    Map<Integer, String> relations = new HashMap<>();
    @PostConstruct
    public void init() {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
        relations.put(3, "老公");
        relations.put(4, "老婆");
        relations.put(5, "儿子");
        relations.put(6, "女儿");
        relations.put(7, "未知");
    }
    /**
     * 查询患者是否还有未结束的三师咨询
     *
@ -665,8 +683,13 @@ public class ConsultTeamService extends ConsultService {
     * @return
     * @throws Exception
     */
    public int addTeamConsult(ConsultTeam ct, String patient) throws Exception {
    public int addTeamConsult(ConsultTeam ct, String patient,String agent) throws Exception {
        JSONObject users = new JSONObject();
        if(patient.equals(agent)){
            agent = null;
        }
        // 咨询三师
        if (ct.getType() == 1) {
            // 查询三师签约信息
@ -770,7 +793,7 @@ public class ConsultTeamService extends ConsultService {
        //推送给IM去创建议题,取得成员消息
//        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), "咨询问题:"+consult.getSymptoms(), consult.getImages());
        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages());
        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(),agent);
        users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
        JSONObject obj = ImUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
        if (obj == null) {
@ -1299,6 +1322,35 @@ public class ConsultTeamService extends ConsultService {
        }
    }
    /**
     * 进入咨询
     * @param consult
     * @param patient
     * @param agent
     * @return
     */
    public int intoTopic(String consult,String patient,String agent) throws Exception{
        ConsultTeam ct = consultTeamDao.findByConsult(consult);
        if(ct.getStatus()!=0){
            return -1;
        }
        String content = "进入了咨询";
        Patient p = patientDao.findByCode(patient);
        String intoUserName = p.getName();
        if(patient.equals(agent)){
            content = intoUserName+content;
        }else {
            PatientFamilyMember familyMember = familyMemberDao.findByPatientAndFamilyMember(patient,agent);
            Patient member = patientDao.findByCode(agent);
            content = member.getName() + "("+relations.get(familyMember.getFamilyRelation())+")"+content;
        }
        ImUtill.sendIntoTopicIM(ct.getPatient(),ct.getPatient(),ct.getConsult(),content,agent,intoUserName);
        return 0;
    }
    /**
     * @param ct
     * @param uid
@ -1618,7 +1670,7 @@ public class ConsultTeamService extends ConsultService {
            qiuzuObj.put("old_consult_code", oldConsultCode);
            qiuzuObj.put("doctor", ct.getDoctor());
            qiuzuObj.put("doctor_name", doctorTemp.getName());
            ImUtill.sendTopicIM(doctor.getCode(), doctor.getName(), oldConsultCode, "5", qiuzuObj.toString());
            ImUtill.sendTopicIM(doctor.getCode(), doctor.getName(), oldConsultCode, "5", qiuzuObj.toString(),null);
        }
@ -1675,7 +1727,7 @@ public class ConsultTeamService extends ConsultService {
        // 添加医生咨询日志
        String content = addLogs(ct);
        if (StringUtils.isBlank(oldConsultCode)) {
            JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, consult.getImages());
            JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, consult.getImages(),null);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put(ct.getPatient(), 0);
            jsonObject.put(ct.getDoctor(), 0);
@ -1691,7 +1743,7 @@ public class ConsultTeamService extends ConsultService {
            ConsultTeam consultTeam = consultTeamDao.findByConsult(oldConsultCode);
            ct.setTeam(oldConsultCode);
            if (oldConsult != null && isSend == 1) {
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), "居民问题:" + oldConsult.getSymptoms(), oldConsult.getImages());
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), "居民问题:" + oldConsult.getSymptoms(), oldConsult.getImages(),null);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
@ -1701,14 +1753,14 @@ public class ConsultTeamService extends ConsultService {
                }
                ct.setStartMsgId(obj.get("start_msg_id").toString());
                Thread.sleep(100);//消息发送顺序问题处理
                ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "6", content);
                ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "6", content, null);
                if (StringUtils.isNotBlank(consult.getImages())) {
                    String imgs[] = consult.getImages().split(",");
                    for (String url : imgs)
                        ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "2", url);
                        ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "2", url, null);
                }
            } else if (oldConsult != null && isSend == 0) {
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, oldConsult.getImages());
                JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, oldConsult.getImages(),null);
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(ct.getPatient(), 0);
                jsonObject.put(ct.getDoctor(), 0);
@ -1723,7 +1775,7 @@ public class ConsultTeamService extends ConsultService {
            qiuzuObj.put("old_consult_code", oldConsultCode);
            qiuzuObj.put("doctor", ct.getDoctor());
            qiuzuObj.put("doctor_name", doctor.getName());
            ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString());
            ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString(), null);
        }
        consultTeamDao.save(ct);  // 保存医生咨询信息
        consultTeamDoctorDao.save(cd);
@ -1802,10 +1854,12 @@ public class ConsultTeamService extends ConsultService {
     * @param ct
     * @param uid
     * @param type 1患者 2医生
     * @param agent 代理人
     * @throws Exception
     */
    public JSONObject famousConsult(ConsultTeam ct, String uid, String type) throws Exception {
    public JSONObject famousConsult(ConsultTeam ct, String uid, String type,String agent) throws Exception {
        // 设置患者信息
        agent = uid.equals(agent)?null:agent;
        ct.setPatient(uid);
        String senderId = "";
        String senderName = "";
@ -1865,7 +1919,7 @@ public class ConsultTeamService extends ConsultService {
        jsonObject.put(ct.getPatient(), 0);
        jsonObject.put(ct.getDoctor(), 0);
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages());
        JSONObject messages = ImUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages(),agent);
        JSONObject obj = ImUtill.createTopics(null, consult.getCode(), consult.getSymptoms(), jsonObject, messages, ImUtill.SESSION_TYPE_P2P);
        if (obj == null) {
@ -1908,9 +1962,16 @@ public class ConsultTeamService extends ConsultService {
                String SQL = "SELECT t.id FROM wlyy_sign_family_renew t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+DateUtil.getSignYear()+"' AND t.patient ='"+uid+"' ";
                String SQL2 ="SELECT t.id FROM wlyy_sign_family t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+(DateUtil.getSignYear()-1)+"' AND t.patient ='"+uid+"' AND t.status>0 AND t.expenses_status ='1' ";
                List<Map<String,Object>> isExits = jdbcTemplate.queryForList(SQL);
                if(isExits!=null&&isExits.size()>0){
                    indexs.add(i);
                List<Map<String,Object>> isExitsSign = jdbcTemplate.queryForList(SQL2);
                if(isExitsSign==null){
                    if(isExits!=null&&isExits.size()>0){
                        indexs.add(i);
                    }
                }
            }
            if(indexs!=null&&indexs.size()>0){
@ -1930,9 +1991,16 @@ public class ConsultTeamService extends ConsultService {
                String SQL = "SELECT t.id FROM wlyy_sign_family_renew t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+DateUtil.getSignYear()+"' AND t.patient ='"+uid+"' ";
                String SQL2 ="SELECT t.id FROM wlyy_sign_family t " +
                        " WHERE (t.doctor ='"+code+"' OR t.doctor_health ='"+code+"' ) " +
                        " AND t.sign_year ='"+(DateUtil.getSignYear()-1)+"' AND t.patient ='"+uid+"' AND t.status>0 AND t.expenses_status ='1' ";
                List<Map<String,Object>> isExits = jdbcTemplate.queryForList(SQL);
                if(isExits!=null&&isExits.size()>0){
                    indexs.add(i);
                List<Map<String,Object>> isExitsSign = jdbcTemplate.queryForList(SQL2);
                if(isExitsSign==null){
                    if(isExits!=null&&isExits.size()>0){
                        indexs.add(i);
                    }
                }
            }
            if(indexs!=null&&indexs.size()>0){

+ 243 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -25,10 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 家庭成员服务
@ -128,6 +125,7 @@ public class FamilyMemberService extends BaseService {
            fm.setFamilyMember(member);
        }
        fm.setFamilyRelation(relation);
        fm.setIsAuthorize(1);//默认授权
        fm.setCzrq(new Date());
        // 添加对方与自己的关系
@ -143,6 +141,7 @@ public class FamilyMemberService extends BaseService {
        int relationTrans = familyRelationTrans(p, relation);
        fmt.setFamilyRelation(relationTrans);
        fmt.setCzrq(new Date());
        fmt.setIsAuthorize(1);//默认授权
        memberDao.save(fm);
        memberDao.save(fmt);
@ -185,6 +184,25 @@ public class FamilyMemberService extends BaseService {
        return 1;
    }
    /**
     * 设置授权关系
     * @param patient
     * @param member
     * @param isAuthorize
     * @return
     * @throws Exception
     */
    public int authorizeMember(String patient, String member,Integer isAuthorize) throws Exception{
        PatientFamilyMember fm = memberDao.findByPatientAndFamilyMember(patient, member);
        if(fm==null){
            return -1;
        }
        fm.setIsAuthorize(isAuthorize);
        memberDao.save(fm);
        return 1;
    }
    /**
     * 修改家庭成员关系
@ -295,6 +313,125 @@ public class FamilyMemberService extends BaseService {
        return result;
    }
    public JSONObject getPatient(String patient){
        Patient p = patientDao.findByCode(patient);
        JSONObject obj = new JSONObject();
        List<SignFamily> signs = contractService.findAllSignByPatient(p.getCode());
        boolean ssSign = false;
        boolean jtSign = false;
        for (SignFamily sign : signs) {
            if (sign.getType() == 1 && sign.getStatus() > 0) {
                ssSign = true;
            } else if (sign.getType() == 2 && sign.getStatus() > 0) {
                jtSign = true;
            } else if (sign.getStatus() == 0) {
            }
        }
        obj.put("code", p.getCode());
        obj.put("name", p.getName());
        obj.put("sex", p.getSex());
        obj.put("birthday", p.getBirthday());
        obj.put("isAuthorize", 1);
        obj.put("idcard", StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard());
        obj.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
        obj.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
        obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
        obj.put("familyRelation", -1);
        obj.put("familyRelationName", "自己");
        obj.put("isAuthorize", 1);//0:未授权,1:已授权
        if (ssSign && jtSign) {
            obj.put("signType", 3);
        } else if (!ssSign && jtSign) {
            obj.put("signType", 2);
        } else if (ssSign && !jtSign) {
            obj.put("signType", 1);
        } else {
            obj.put("signType", 0);
        }
        return obj;
    }
    /**
     * 获取所有家庭成员,包括自己
     * @param patient
     * @return
     */
    public JSONArray getAllFamilyMembers(String patient){
        JSONArray resultArray = new JSONArray();
        resultArray.put(getPatient(patient));
        String sql = "select * " +
                " from " +
                "    wlyy_patient_family_member t1, " +
                "    wlyy_patient t2 " +
                " where " +
                "    t2.code in (select family_member from wlyy_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.code order by t1.family_relation ASC ";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
            JSONArray tem = new JSONArray();//存储其他
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                List<SignFamily> signs = contractService.findAllSignByPatient(map.get("code").toString());
                boolean ssSign = false;
                boolean jtSign = false;
                for (SignFamily sign : signs) {
                    if (sign.getType() == 1 && sign.getStatus() > 0) {
                        ssSign = true;
                    } else if (sign.getType() == 2 && sign.getStatus() > 0) {
                        jtSign = true;
                    } else if (sign.getStatus() == 0) {
                    }
                }
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", family_relation);
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                if (ssSign && jtSign) {
                    obj.put("signType", 3);
                } else if (!ssSign && jtSign) {
                    obj.put("signType", 2);
                } else if (ssSign && !jtSign) {
                    obj.put("signType", 1);
                } else {
                    obj.put("signType", 0);
                }
                if(family_relation==0){
                    tem.put(obj);
                }else {
                    resultArray.put(obj);
                }
            }
            if(tem.length()>0){
                for(int i =0;i<tem.length();i++){
                    resultArray.put(tem.get(i));
                }
            }
        }
        return resultArray;
    }
    /**
     * 获取居民的家庭成员
     *
@ -345,6 +482,7 @@ public class FamilyMemberService extends BaseService {
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
@ -378,6 +516,105 @@ public class FamilyMemberService extends BaseService {
        return resultArray;
    }
    /**
     * 是否授权,如果有授权就返回member的个人信息
     * @param patient
     * @param member
     * @return
     */
    public JSONObject isAuthorize(String patient,String member){
        JSONObject json = new JSONObject();
        PatientFamilyMember familyMember = memberDao.findByPatientAndFamilyMember(patient,member);
        if(familyMember==null||0==familyMember.getIsAuthorize()){
            return null;
        }
        Patient p = patientDao.findByCode(member);
        json.put("code", p.getCode());
        json.put("name", p.getName());
        return json;
    }
    /**
     * 获取有授权的家庭成员
     * @param patient
     * @return
     */
    public JSONArray getAuthorizeMembers(String patient){
        JSONArray resultArray = new JSONArray();
        resultArray.put(getPatient(patient));
        String sql = "select * " +
                " from " +
                "    wlyy_patient_family_member t1, " +
                "    wlyy_patient t2 " +
                " where " +
                "        t1.patient = ? " +
                "    and t1.is_authorize = 1 " +
                "    and t1.family_member = t2.code order by t1.family_relation ";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient});
        if (result != null && result.size() > 0) {
            JSONArray tem = new JSONArray();
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                List<SignFamily> signs = contractService.findAllSignByPatient(map.get("code").toString());
                boolean ssSign = false;
                boolean jtSign = false;
                for (SignFamily sign : signs) {
                    if (sign.getType() == 1 && sign.getStatus() > 0) {
                        ssSign = true;
                    } else if (sign.getType() == 2 && sign.getStatus() > 0) {
                        jtSign = true;
                    } else if (sign.getStatus() == 0) {
                    }
                }
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                String idCard = StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString();
                obj.put("idcard", CommonUtil.getIdcardEncode(idCard));
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("ssc", map.get("ssc"));
                obj.put("familyRelation", family_relation);
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                if (ssSign && jtSign) {
                    obj.put("signType", 3);
                } else if (!ssSign && jtSign) {
                    obj.put("signType", 2);
                } else if (ssSign && !jtSign) {
                    obj.put("signType", 1);
                } else {
                    obj.put("signType", 0);
                }
                if(family_relation==0){
                    tem.put(obj);
                }else {
                    resultArray.put(obj);
                }
            }
            if(tem.length()>0){
                for(int i =0;i<tem.length();i++){
                    resultArray.put(tem.get(i));
                }
            }
        }
        return resultArray;
    }
    /**
     * 获取居民的家庭成员
@ -419,6 +656,7 @@ public class FamilyMemberService extends BaseService {
            obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
            obj.put("familyRelation", "-1");
            obj.put("familyRelationName", "自己");
            obj.put("isAuthorize", 1);//0:未授权,1:已授权
            if (ssSign && jtSign) {
                obj.put("signType", 3);
@ -872,7 +1110,7 @@ public class FamilyMemberService extends BaseService {
        String result = HttpUtil.sendGet(userInfo_url, params);
        JSONObject json = new JSONObject(result);
        if (json.has("subscribe")) {
            return json.get("subscribe").toString();
            return json.get(" ").toString();
        } else {
            return null;
        }

+ 240 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -0,0 +1,240 @@
package com.yihu.wlyy.service.app.prenatalInspector;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlanLibrary;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPreCard;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PrenatalInspectorPlanDao;
import com.yihu.wlyy.repository.patient.PrenatalInspectorPlanLibraryDao;
import com.yihu.wlyy.repository.patient.PrenatalInspectorPreCardDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2017/6/6.
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class PrenatalInspectorPreCardService extends BaseService {
    @Autowired
    private PrenatalInspectorPreCardDao prenatalInspectorPreCardDao;
    @Autowired
    private PrenatalInspectorPlanLibraryDao prenatalInspectorPlanLibraryDao;
    @Autowired
    private PrenatalInspectorPlanDao prenatalInspectorPlanDao;
    @Autowired
    private WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private FamilyContractService familyContractService;
    /**
     * 待产检计划
     * @param code
     * @return
     */
    public JSONArray planList(String code){
        JSONArray jsonArray = new JSONArray();
        List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findByCode(code);
        for (PrenatalInspectorPlan plan:planList){
            JSONObject json = new JSONObject();
            json.put("checkItem",plan.getCheckItem());
            json.put("name",plan.getName());
            json.put("thisFoucs",plan.getThisFocus());
            json.put("thisNote",plan.getThisNote());
            if(plan.getInspectionTime()==null){
                json.put("inspectionTime","");
            }else {
                json.put("inspectionTime",DateUtil.dateToStrShort(plan.getInspectionTime()));
            }
            json.put("inspectionEndTime",DateUtil.dateToStrShort(plan.getInspectionEndTime()));
            json.put("inspectionStartTime",DateUtil.dateToStrShort(plan.getInspectionStartTime()));
            jsonArray.put(json);
        }
        return jsonArray;
    }
    /**
     * 预建卡列表-孕检计划
     * @param patient
     * @return
     */
    public JSONArray preCardList(String patient){
        JSONArray jsonArray = new JSONArray();
        List<PrenatalInspectorPreCard> preCards = prenatalInspectorPreCardDao.findByPatient(patient);
        for (PrenatalInspectorPreCard preCard:preCards){
            JSONObject json = new JSONObject();
            json.put("code",preCard.getCode());
            json.put("dueDate",DateUtil.dateToStrShort(preCard.getDueDate()));//预产期
            Date date = new Date();
            Long dueDateDay = DateUtil.getDays(preCard.getDueDate(),date);
            if(dueDateDay>0){
                json.put("dueDateWeek",getWeek(dueDateDay.intValue()));//距离预产期周数
                json.put("dueDateDay",getDay(dueDateDay.intValue()));//距离预产期周数的余数
                Long pregnancyDay = DateUtil.getDays(date,preCard.getLastMenstrualDate());
                int week = getWeek(pregnancyDay.intValue());
                int day = getDay(pregnancyDay.intValue());
                String preDay = day==0?(week+"周"):(week+"周"+day+"天");//怀孕时间
                json.put("status",preDay);
            }else {
                json.put("dueDateWeek",0);//距离预产期周数
                json.put("dueDateDay",0);//距离预产期周数的余数
                json.put("status",preCard.getStatus());
            }
            json.put("hospitalName",preCard.getHospitalName());//预约床位医院
            json.put("orderBedTime",preCard.getOrderBedTime());//预约床位时间
            jsonArray.put(json);
        }
        return jsonArray;
    }
    /**
     * 把天数换算成周数
     * @param day
     * @return
     */
    private int getWeek(Integer day){
        return day/7;
    }
    /**
     * 把天数换算成周数的余数
     * @param day
     * @return
     */
    private int getDay(Integer day){
        return day%7;
    }
    /**
     * 新建产检预建卡
     */
    @Transactional
    public void addPrenatalInspectorPreCard(PrenatalInspectorPreCard preCard){
        //1、保存预建卡
        Date date = new Date();
        Date lastMenstrualDate = preCard.getLastMenstrualDate();
        preCard.setDel("1");
        preCard.setCode(getCode());
        preCard.setCzrq(date);
        preCard.setDueDate(DateUtil.getDueDate(preCard.getLastMenstrualDate()));//预产期
        preCard.setStatus("0");
        preCard.setEffective("");
        preCard.setInspectionPhase("1");//检查阶段
        prenatalInspectorPreCardDao.save(preCard);
        String patient = preCard.getPatient();
        //2、生成待产检计划
        Long days = DateUtil.getDays(date,lastMenstrualDate);
        List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
        List<PrenatalInspectorPlan> plans = new ArrayList<>();
        PrenatalInspectorPlan plan = null;
        for (PrenatalInspectorPlanLibrary library:libraries){
            plan = new PrenatalInspectorPlan();
            plan.setInspectionPhase(library.getInspectionPhase());
            plan.setStatus("0");
            plan.setPatient(patient);
            plan.setCzrq(date);
            plan.setCheckItem(library.getCheckItem());
            plan.setInspectionCode(preCard.getCode());
            plan.setInspectionEndTime(DateUtil.getPrenatalInspectorDate(lastMenstrualDate,library.getEndDay().intValue()));
            plan.setInspectionStartTime(DateUtil.getPrenatalInspectorDate(lastMenstrualDate,library.getStartDay().intValue()));
            plan.setName(library.getName());
            plan.setThisFocus(library.getThisFocus());
            plan.setThisNote(library.getThisNote());
            if("1".equals(plan.getInspectionPhase())){
                SignFamily jiating = familyContractService.findByPatientByType(patient, 2);
                if(jiating!=null){
                    plan.setSignHospital(jiating.getHospital());
                }
            }
            plans.add(plan);
        }
        if (plans.size()>0){
            prenatalInspectorPlanDao.save(plans);
        }
    }
    /**
     * 产检提醒(1预约提醒,2就诊提醒)
     * 1、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前7天(保证居民可自行预约),发出产检预约提醒通知。点击该消息,进入预约页面
     * 2、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前1天,发出产检就诊提醒,提醒居民就诊。点击该消息,进入预约记录页面
     */
    public void sendPrenatalInspectorRemind(){
        System.out.println("产检计划---running");
        List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findWxTipList();
        for (PrenatalInspectorPlan plan:planList){
            try {
                Patient patient = patientDao.findByCode(plan.getPatient());
                String openId = patient.getOpenid();
                String name = patient.getName();
                String patientCode = patient.getCode();
                if(StringUtils.isNotBlank(openId)){
                    Long day = DateUtil.getDays(plan.getInspectionTime(),DateUtil.getNowDateShort());
                    JSONObject json = new JSONObject();
                    if(day==7){
                        //产检提醒
                        json.put("remark","产检内容以医生实际检查为准。点击进行预约");
                        json.put("first",name+",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略");
                        if("1".equals(plan.getInspectionPhase())){
                            if(StringUtils.isNotBlank(plan.getSignHospital())){
                                json.put("url","wdyy/html/hospital-dept.html?openid="+openId+"&toUser="+patientCode+"&toName="+name+"&hospitalId="+plan.getSignHospital());
                            }else {
                                json.put("url","wdyy/html/appointment-register.html?openid="+openId+"&toUser="+patientCode+"&toName="+name+"&orderType=1");
                            }
                        }else {
                            json.put("url","wdyy/html/appointment-register.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
                        }
                        json.put("keyword1","产检提醒");
                        String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
                        json.put("keyword2",keyword2);
                        PushMsgTask.getInstance().sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                    }else if(day==1){
                        //产检就诊提醒
                        json.put("remark","产检内容以医生实际检查为准。点击查看预约记录");
                        json.put("first",name+",您好!您和您的宝宝即将进行产检啦~请按时就诊,如已就诊,请忽略");
                        json.put("url","wdyy/html/my-appointment.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
                        json.put("keyword1","产检就诊提醒");
                        String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
                        json.put("keyword2",keyword2);
                        PushMsgTask.getInstance().sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                    }
                }
            }catch (Exception e){
                System.out.println("微信提醒发送失败");
                e.printStackTrace();
            }
        }
    }
}

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

@ -2991,16 +2991,16 @@ public class FamilyContractService extends BaseService {
        }else {
            //如果不一致 查看医生团队
            sf.setRenewFlag("2");
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
            if(ids!=null&&ids.size()>0){
                Integer id =  (Integer)ids.get(0).get("id");
                Long lid = id.longValue();
                sf.setAdminTeamId(lid);
            }else{
                //未找到团队信息
                return -5;
            }
//            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
//            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
//            if(ids!=null&&ids.size()>0){
//                Integer id =  (Integer)ids.get(0).get("id");
//                Long lid = id.longValue();
//                sf.setAdminTeamId(lid);
//            }else{
//                //未找到团队信息
//                return -5;
//            }
            //新建咨询团队组
            DoctorTeam team = new DoctorTeam();
            String code = getCode();
@ -3176,16 +3176,16 @@ public class FamilyContractService extends BaseService {
            sf.setAdminTeamId(c.longValue());
        }else {
            //如果不一致 查看医生团队
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
            if(ids!=null&&ids.size()>0){
                Integer id =  (Integer)ids.get(0).get("id");
                Long lid = id.longValue();
                sf.setAdminTeamId(lid);
            }else{
                //未找到团队信息
                return -5;
            }
//            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
//            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
//            if(ids!=null&&ids.size()>0){
//                Integer id =  (Integer)ids.get(0).get("id");
//                Long lid = id.longValue();
//                sf.setAdminTeamId(lid);
//            }else{
//                //未找到团队信息
//                return -5;
//            }
            //新建咨询团队组
            DoctorTeam team = new DoctorTeam();
            String code = getCode();

+ 642 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -14,6 +14,7 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MapListUtils;
import com.yihu.wlyy.util.SystemConf;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -2206,4 +2207,645 @@ public class StatisticsService extends BaseService {
        }
        return 0;
    }
    /**
     * 获取团队月或周咨询未回复和总数折线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type 0周,1月
     * @return
     */
    public JSONObject getTeamConsultCount(String teamCode,String startDate,String endDate,String type){
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        String sql ;
        String totalSql ;
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        if("0".equals(type)){
            //按周统计
            sql = "SELECT " +
                    " left(a.czrq,10) AS dateNo,count(1) AS noRely " +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE" +
                    " a.czrq <= '"+endDate+"'" +
                    " AND a.czrq >= '"+startDate+"'" +
                    " AND a.admin_team_code ="+teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t, " +
                    " "+imDataBaseName+".participants p, " +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " )" +
                    " GROUP BY left(a.czrq,10)";
            totalSql ="SELECT " +
                    " left(a.czrq,10) AS dateNo,count(1) AS total " +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE" +
                    " a.czrq <= '"+endDate+"'" +
                    " AND a.czrq >= '"+startDate+"'" +
                    " AND a.admin_team_code ="+teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t, " +
                    " "+imDataBaseName+".participants p, " +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " )" +
                    " GROUP BY left(a.czrq,10)";
        }else{
            //按月统计
            sql = "SELECT " +
                    " ( " +
                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" +
                    " ) AS weekOfMonth, " +
                    "  COUNT(1) AS noRely" +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE " +
                    " a.czrq <= '"+endDate+"' " +
                    " AND a.czrq >= '"+startDate+"' " +
                    " AND a.admin_team_code =" +teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t," +
                    " "+imDataBaseName+".participants p," +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " )" +
                    " GROUP BY " +
                    " DATE_FORMAT(a.czrq, '%m %v')";
            totalSql ="SELECT " +
                    " ( " +
                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" +
                    " ) AS weekOfMonth, " +
                    "  COUNT(1) AS total" +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE " +
                    " a.czrq <= '"+endDate+"' " +
                    " AND a.czrq >= '"+startDate+"' " +
                    " AND a.admin_team_code =" +teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t," +
                    " "+imDataBaseName+".participants p," +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " )" +
                    " GROUP BY " +
                    " DATE_FORMAT(a.czrq, '%m %v')";
        }
        List<Map<String,Object>> noReyList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        JSONObject result = new JSONObject();
        result.put("noReyList",noReyList);
        result.put("totalList",totalList);
        return result;
    }
    /**
     *  计算团队医生月或周咨询未回复和总数折线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type
     * @param doctor 医生code
     * @return
     */
    public JSONObject getTeamDocotorConsultCount(String teamCode,String startDate,String endDate,String type,String doctor){
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        String sql ;
        String totalSql ;
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        if("0".equals(type)){
            //按周统计
            sql = "SELECT " +
                    " left(a.czrq,10) AS dateNo,count(1) AS noRely " +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE" +
                    " a.czrq <= '"+endDate+"'" +
                    " AND a.czrq >= '"+startDate+"'" +
                    " AND a.admin_team_code ="+teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t, " +
                    " "+imDataBaseName+".participants p, " +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " AND d.id = '"+doctor+"'"+
                    " )" +
                    " GROUP BY left(a.czrq,10)";
            totalSql ="SELECT " +
                    " left(a.czrq,10) AS dateNo,count(1) AS total " +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE" +
                    " a.czrq <= '"+endDate+"'" +
                    " AND a.czrq >= '"+startDate+"'" +
                    " AND a.admin_team_code ="+teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t, " +
                    " "+imDataBaseName+".participants p, " +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " AND d.id = '"+doctor+"'"+
                    " )" +
                    " GROUP BY left(a.czrq,10)";
        }else{
            //按月统计
            sql = "SELECT " +
                    " ( " +
                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" +
                    " ) AS weekOfMonth, " +
                    "  COUNT(1) AS noRely" +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE " +
                    " a.czrq <= '"+endDate+"' " +
                    " AND a.czrq >= '"+startDate+"' " +
                    " AND a.admin_team_code =" +teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t," +
                    " "+imDataBaseName+".participants p," +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t. STATUS <> 10 " +
                    " AND t.`reply` = 0 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " AND d.id = '"+doctor+"'"+
                    " )" +
                    " GROUP BY " +
                    " DATE_FORMAT(a.czrq, '%m %v')";
            totalSql ="SELECT " +
                    " ( " +
                    " DATE_FORMAT(a.czrq, '%v') - DATE_FORMAT('"+DateUtil.getFristDayOfMonth()+"', '%v') + 1" +
                    " ) AS weekOfMonth, " +
                    "  COUNT(1) AS total" +
                    " FROM " +
                    " wlyy_consult_team a " +
                    " WHERE " +
                    " a.czrq <= '"+endDate+"' " +
                    " AND a.czrq >= '"+startDate+"' " +
                    " AND a.admin_team_code =" +teamCode+
                    " AND a.consult IN (" +
                    " SELECT DISTINCT " +
                    " t.id consultId " +
                    " FROM " +
                    " "+imDataBaseName+".topics t," +
                    " "+imDataBaseName+".participants p," +
                    " "+imDataBaseName+".doctors d, " +
                    " "+imDataBaseName+".sessions s " +
                    " WHERE " +
                    " p.participant_id = d.id " +
                    " AND t.session_id = p.session_id " +
                    " AND t.session_id = s.id " +
                    " AND s.type = 1 " +
                    " AND t.create_time <= '"+endDate+"'" +
                    " AND t.create_time >= '"+startDate+"'" +
                    " AND d.id = '"+doctor+"'"+
                    " )" +
                    " GROUP BY " +
                    " DATE_FORMAT(a.czrq, '%m %v')";
        }
        List<Map<String,Object>> noReyList = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        JSONObject result = new JSONObject();
        result.put("noReyList",noReyList);
        result.put("totalList",totalList);
        return result;
    }
    /**
     * 获取团队咨询情况列表
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort 0降序 1升续
     * @return
     */
    public JSONArray getMemberConsultList(String teamCode,String startDate,String endDate,String sort){
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        // 未回复咨询总量
        String onReySQL = "SELECT " +
                " t.doctor_code AS doctorCode, " +
                " d.`name`, " +
                " IFNULL(r.noRely,0) AS noRely " +
                " FROM" +
                " wlyy_admin_team_member t " +
                " LEFT JOIN (" +
                " SELECT " +
                "  c.doctorCode, " +
                "  count(1) AS noRely " +
                " FROM " +
                " wlyy_consult_team a," +
                " ( " +
                " SELECT DISTINCT " +
                " t.id consultId, " +
                " d.id doctorCode " +
                " FROM " +
                " "+imDataBaseName+".topics t, " +
                " "+imDataBaseName+".participants p, " +
                " "+imDataBaseName+".doctors d, " +
                " "+imDataBaseName+".sessions s " +
                " WHERE " +
                " p.participant_id = d.id " +
                " AND t.session_id = p.session_id " +
                " AND t.session_id = s.id " +
                " AND s.type = 1 " +
                " AND t. STATUS <> 10 " +
                " AND t.`reply` = 0 " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND t.create_time >= '"+startDate+"' " +
                " ) c" +
                " WHERE " +
                " c.consultId = a.consult " +
                " AND a.admin_team_code = " +teamCode+
                " GROUP BY " +
                " c.doctorCode " +
                " ) r ON r.doctorCode = t.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE " +
                " t.doctor_code = d.`code` " +
                " AND t.available = 1 " +
                " AND t.team_id = "+teamCode ;
        if("0".equals(sort)){
            onReySQL = onReySQL+ " ORDER BY noRely DESC";
        }else{
            onReySQL = onReySQL+ " ORDER BY noRely ASC";
        }
        //总咨询量
        String totalSql ="SELECT " +
                " t.doctor_code AS doctorCode, " +
                " d.`name`, " +
                " IFNULL(r.total,0) AS total " +
                "FROM " +
                " wlyy_admin_team_member t " +
                "LEFT JOIN ( " +
                " SELECT " +
                " c.doctorCode, " +
                " count(1) AS total " +
                " FROM " +
                " wlyy__team a, " +
                " ( " +
                " SELECT DISTINCT " +
                " t.id consultId, " +
                " d.id doctorCode " +
                " FROM " +
                " "+imDataBaseName+".topics t, " +
                " "+imDataBaseName+".participants p, " +
                " "+imDataBaseName+".doctors d, " +
                " "+imDataBaseName+".sessions s " +
                " WHERE " +
                " tp.participant_id = d.id " +
                " AND t.session_id = p.session_id " +
                " AND t.session_id = s.id " +
                " AND s.type = 1 " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND t.create_time >= '"+startDate+"' " +
                " ) c " +
                " WHERE " +
                " c.consultId = a.consult " +
                " AND a.admin_team_code = " +teamCode+
                " GROUP BY " +
                " c.doctorCode " +
                ") r ON r.doctorCode = t.doctor_code, " +
                " wlyy_doctor d " +
                "WHERE " +
                " t.doctor_code = d.`code` " +
                "AND t.available = 1 " +
                "AND t.team_id =  "+teamCode ;
        //结束咨询
        String endConsultSql ="SELECT " +
                " t.doctor_code doctorCode, " +
                " d.`name`, " +
                " IFNULL(r.endRey,0) AS endRey " +
                "FROM " +
                " wlyy_admin_team_member t " +
                "LEFT JOIN ( " +
                " SELECT " +
                "  c.doctorCode, " +
                "  count(1) AS endRey " +
                " FROM " +
                "  wlyy_consult_team a, " +
                "  ( " +
                " SELECT DISTINCT " +
                " t.id consultId, " +
                " d.id doctorCode " +
                " FROM " +
                " "+imDataBaseName+".topics t, " +
                " "+imDataBaseName+".participants p, " +
                " "+imDataBaseName+".doctors d, " +
                " "+imDataBaseName+".sessions s " +
                " WHERE " +
                " p.participant_id = d.id " +
                " AND t.session_id = p.session_id " +
                " AND t.session_id = s.id " +
                " AND s.type = 1 " +
                " AND t. STATUS = 10 " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND t.create_time >= '"+startDate+"' " +
                " ) c " +
                " WHERE " +
                " c.consultId = a.consult " +
                " AND a.admin_team_code =" +teamCode+
                " GROUP BY " +
                " c.doctorCode " +
                ") r ON r.doctorCode = t.doctor_code, " +
                " wlyy_doctor d " +
                " WHERE " +
                " t.doctor_code = d.`code` " +
                " AND t.available = 1 " +
                " AND t.team_id = "+teamCode;
        List<Map<String,Object>> onReyList = jdbcTemplate.queryForList(onReySQL);
        List<Map<String,Object>> totalList = jdbcTemplate.queryForList(totalSql);
        Map<String,Object> totalMap = new HashMap<>();
        //将List转换为Map降低循环层级
        if(totalList!=null&&totalList.size()>0){
            for(Map<String,Object> list :totalList){
                String code = (String)list.get("doctorCode");
                totalMap.put(code,list);
            }
        }
        List<Map<String,Object>> endConsultList = jdbcTemplate.queryForList(endConsultSql);
        //将List转换为Map降低循环层级
        Map<String,Object> endConsultMap = new HashMap<>();
        //将List转换为Map降低循环层级
        if(endConsultList!=null&&endConsultList.size()>0){
            for(Map<String,Object> list :endConsultList){
                String code = (String)list.get("doctorCode");
                endConsultMap.put(code,list);
            }
        }
        //合并结果集
        if(onReyList!=null&&onReyList.size()>0){
            for(Map<String,Object> map :onReyList){
                String code = (String)map.get("doctorCode");
                Map<String,Object> t = ( Map<String,Object>)totalMap.get(code);
                Long totalCout = (Long)t.get("total");
                map.put("total",totalCout);
                Map<String,Object> e =( Map<String,Object>)endConsultMap.get(code);
                Long endCout = (Long)e.get("endRey");
                map.put("endRey",endCout);
            }
        }
        return new JSONArray(onReyList);
    }
    public JSONObject getDoctorConsultTitle(String doctor,String teamCode,String startDate,String endDate){
        String imDataBaseName = SystemConf.getInstance().getImDataBaseName();
        startDate = startDate+" 00:00:00";
        endDate = endDate+" 23:59:59";
        //获取咨询总数
        String couTotalSQL = "SELECT " +
                " c.doctorCode, " +
                " count(1) AS total " +
                " FROM " +
                " wlyy_consult_team a, " +
                " ( " +
                " SELECT DISTINCT " +
                " t.id consultId, " +
                " d.id doctorCode " +
                " FROM " +
                " "+imDataBaseName+".topics t, " +
                " "+imDataBaseName+".participants p, " +
                " "+imDataBaseName+".doctors d, " +
                " "+imDataBaseName+".sessions s " +
                " WHERE " +
                " p.participant_id = d.id " +
                " AND t.session_id = p.session_id " +
                " AND t.session_id = s.id " +
                " AND s.type = 1 " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND d.id='"+doctor+"' " +
                " ) c " +
                " WHERE " +
                " c.consultId = a.consult " +
                " AND a.admin_team_code = " +teamCode +
                " GROUP BY " +
                " c.doctorCode ";
        //及时回复数
        String reyTotalSql ="SELECT " +
                " c.doctorCode, " +
                " count(1) AS total " +
                " FROM " +
                " wlyy_consult_team a, " +
                " ( " +
                " SELECT DISTINCT " +
                " t.id consultId, " +
                " d.id doctorCode " +
                " FROM " +
                " "+imDataBaseName+".topics t, " +
                " "+imDataBaseName+".participants p, " +
                " "+imDataBaseName+".doctors d, " +
                " "+imDataBaseName+".sessions s " +
                " WHERE " +
                " p.participant_id = d.id " +
                " AND t.session_id = p.session_id " +
                " AND t.session_id = s.id " +
                " AND s.business_type=2  " +
                " AND t.`reply`=1  " +
                " AND TIMESTAMPDIFF(SECOND ,t.create_time ,t.reply_time) <86400 AND TIMESTAMPDIFF(SECOND ,t.create_time,t.reply_time) >0 " +
                " AND t.create_time <= '"+endDate+"' " +
                " AND d.id='"+doctor+"' " +
                " ) c " +
                " WHERE " +
                " c.consultId = a.consult " +
                " AND a.admin_team_code =" +teamCode+
                " GROUP BY " +
                " c.doctorCode";
        //本周或月增量
        String addTotalSql ="SELECT " +
                "  c.doctorCode, " +
                "  count(1) AS total " +
                " FROM " +
                "  wlyy_consult_team a, " +
                "  ( " +
                "   SELECT DISTINCT " +
                " t.id consultId," +
                " d.id doctorCode " +
                " FROM " +
                "    "+imDataBaseName+".topics t, " +
                "    "+imDataBaseName+".participants p, " +
                "    "+imDataBaseName+".doctors d, " +
                "    "+imDataBaseName+".sessions s " +
                "   WHERE " +
                "    p.participant_id = d.id " +
                "   AND t.session_id = p.session_id " +
                "   AND t.session_id = s.id " +
                "   AND s.type = 1 " +
                "   AND t.create_time <= '"+endDate+"' " +
                "   AND t.create_time >= '"+startDate+"' " +
                "   AND d.id='"+doctor+"' " +
                "  ) c " +
                " WHERE " +
                "  c.consultId = a.consult " +
                " AND a.admin_team_code =" +teamCode+
                " GROUP BY " +
                "  c.doctorCode";
        //当前未回复咨询数
        String noRelySql ="SELECT " +
                "  c.doctorCode, " +
                "  count(1) AS total " +
                " FROM " +
                "  wlyy_consult_team a, " +
                "  ( " +
                "   SELECT DISTINCT " +
                "    t.id consultId, " +
                "    d.id doctorCode " +
                "   FROM " +
                "    "+imDataBaseName+".topics t, " +
                "    "+imDataBaseName+".participants p, " +
                "    "+imDataBaseName+".doctors d, " +
                "    "+imDataBaseName+".sessions s " +
                "   WHERE " +
                "    p.participant_id = d.id " +
                "   AND t.session_id = p.session_id " +
                "   AND t.session_id = s.id " +
                "   AND s.type = 1  " +
                "   AND t. STATUS <> 10  " +
                "   AND t.`reply` = 0  " +
                "   AND t.create_time <= '"+endDate+"' " +
                "   AND t.create_time >= '"+startDate+"' " +
                "   AND d.id='"+doctor+"' " +
                "  ) c " +
                " WHERE " +
                "  c.consultId = a.consult " +
                "  AND a.admin_team_code =" +teamCode+
                " GROUP BY " +
                "  c.doctorCode";
        JSONObject rs = new JSONObject();
        Long total =0L;
        Long relyOnTime =0L;
        Long addNumber = 0L;
        Long noRelyNumber =0L;
        List<Map<String,Object>> couTotal = jdbcTemplate.queryForList(couTotalSQL);
        if(couTotal!=null&&couTotal.size()>0){
            Map<String,Object> couTotalMap = couTotal.get(0);
            total = (Long) couTotalMap.get("total")==null?0L:(Long) couTotalMap.get("total");
        }
        rs.put("total",total);
        List<Map<String,Object>> reyTotal = jdbcTemplate.queryForList(reyTotalSql);
        if(reyTotal!=null&&reyTotal.size()>0){
            Map<String,Object> reyTotalMap = reyTotal.get(0);
            relyOnTime = (Long) reyTotalMap.get("total")==null?0L:(Long) reyTotalMap.get("total");
        }
        if(total!=0L&&relyOnTime!=0L){
            double rr = (double)relyOnTime/total*100;
            double nrr = (double)relyOnTime/total*100;
            DecimalFormat df  = new DecimalFormat("###.00");
            rs.put("relyOnTimeRate",df.format(nrr)+"%");
        }else{
            rs.put("relyOnTimeRate","0.00%");
        }
        List<Map<String,Object>> addTotal = jdbcTemplate.queryForList(addTotalSql);
        if(addTotal!=null&&addTotal.size()>0){
            Map<String,Object> addTotalMap = addTotal.get(0);
            addNumber = (Long) addTotalMap.get("total")==null?0L:(Long) addTotalMap.get("total");
        }
        //本周或月增量
        rs.put("addNumber",addNumber);
        List<Map<String,Object>> noRelyTotal = jdbcTemplate.queryForList(noRelySql);
        if(noRelyTotal!=null&&noRelyTotal.size()>0){
            Map<String,Object> noRelyTotalMap = noRelyTotal.get(0);
            noRelyNumber = (Long) noRelyTotalMap.get("total")==null?0L:(Long) noRelyTotalMap.get("total");
        }
        rs.put("noRelyNumber",noRelyNumber);
        return rs;
    }
}

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

@ -778,6 +778,8 @@ public class JwArchivesService {
        }
    }
    /**
     * 上传随访记录接口
     */

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

@ -18,6 +18,7 @@ public class Configure {
	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 = "";
	public String getOnepayApi() {
		return onepayApi;
@ -41,6 +42,10 @@ public class Configure {
		return chargeQueryType;
	}
	public String getCreateSicardType() {
		return createSicardType;
	}
	/******************* 微信社保支付配置 ******************************************/
	//这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
	// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证

+ 21 - 28
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/model/Charge.java

@ -6,10 +6,10 @@ package com.yihu.wlyy.service.weixin.wxpay.model;
 */
public class Charge {
    private String tradeStatus; //交易状态    0 成功 1 失败  2 已退款
    private String settleNo;  //医保业务流水号
    private String settleTime;  //  医保交易成功时间
    private String outSettleNo;  //  接入应用业务流水号
    private String outSettleTime;  //  接入应用内业务时间
    private String chargeNo;  //医保业务流水号
    private String chargeTime;  //  医保交易成功时间
    private String outChargeNo;  //  接入应用业务流水号
    private String outChargeTime;  //  接入应用内业务时间
    private String medOrgNo;  //  医疗机构编号
    private String medOrgName;  //  医疗机构名称
    private String billNo;  //  待结算费用单据号
@ -21,7 +21,7 @@ public class Charge {
    private String userName;  // 用户姓名
    private String idType;  // 证件号码
    private String idNo;  // 证件类型
    private String responseContent;  //扣费详情
    //private String responseContent;  //扣费详情
    public String getTradeStatus() {
        return tradeStatus;
@ -31,36 +31,36 @@ public class Charge {
        this.tradeStatus = tradeStatus;
    }
    public String getSettleNo() {
        return settleNo;
    public String getChargeNo() {
        return chargeNo;
    }
    public void setSettleNo(String settleNo) {
        this.settleNo = settleNo;
    public void setChargeNo(String chargeNo) {
        this.chargeNo = chargeNo;
    }
    public String getSettleTime() {
        return settleTime;
    public String getChargeTime() {
        return chargeTime;
    }
    public void setSettleTime(String settleTime) {
        this.settleTime = settleTime;
    public void setChargeTime(String chargeTime) {
        this.chargeTime = chargeTime;
    }
    public String getOutSettleNo() {
        return outSettleNo;
    public String getOutChargeNo() {
        return outChargeNo;
    }
    public void setOutSettleNo(String outSettleNo) {
        this.outSettleNo = outSettleNo;
    public void setOutChargeNo(String outChargeNo) {
        this.outChargeNo = outChargeNo;
    }
    public String getOutSettleTime() {
        return outSettleTime;
    public String getOutChargeTime() {
        return outChargeTime;
    }
    public void setOutSettleTime(String outSettleTime) {
        this.outSettleTime = outSettleTime;
    public void setOutChargeTime(String outChargeTime) {
        this.outChargeTime = outChargeTime;
    }
    public String getMedOrgNo() {
@ -151,11 +151,4 @@ public class Charge {
        this.idNo = idNo;
    }
    public String getResponseContent() {
        return responseContent;
    }
    public void setResponseContent(String responseContent) {
        this.responseContent = responseContent;
    }
}

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

@ -2,21 +2,31 @@ package com.yihu.wlyy.service.weixin.wxpay.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.patient.Patient;
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.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;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 易联众统一支付服务类
@ -37,10 +47,42 @@ public class OnePayService {
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    ChargeDao chargeDao;
    @Autowired
    PatientDao patientDao;
    /**
     *  查询绑卡信息
     */
    public BindCard bindCard(String patient,String openid)  throws Exception
    {
        BindCard card = bindCard(openid);
        //更新患者信息
        if(card!=null)
        {
            Patient p = patientDao.findByCode(patient);
            p.setOpenid(openid);
            p.setSsc(card.getCardNo());
            if(card.getIdType()=="01")      //身份证
            {
                p.setIdcard(card.getIdNo());
            }
            p.setName(card.getUserName());
            patientDao.save(p);
        }
        return card;
    }
    /**
     * 查询绑卡信息
     */
    public BindCard bindCard(String openid) throws Exception
    private BindCard bindCard(String openid) throws Exception
    {
        Boolean isSuccess = true;
        String msgBody = "";
@ -64,11 +106,12 @@ public class OnePayService {
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("userId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getBindCardType());
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            msgBody =  JSON.toJSONString(requestParams);
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response =  JSON.toJSONString(res);
            // 如医保卡绑卡信息返回参数
@ -106,7 +149,7 @@ public class OnePayService {
    /**
     * 家庭医生签约支付
     */
    public String charge(String orgCode,String code,String date,String cardNo,String openid) throws Exception
    public String charge(String orgCode,String chargeType,String chargeRelation,Integer totalAmount,Integer selfpayAmount,Integer insuranceAmount,String feeDetail,String patient,String openid) throws Exception
    {
        //获取机构映射
        HospitalMapping hos = hospitalMappingDao.findByCode(orgCode);
@ -115,60 +158,107 @@ public class OnePayService {
            throw new Exception("no hospital mapping!");
        }
        return charge(hos.getAppId(), hos.getAppSecret(), code, date, cardNo, openid);
        return charge(orgCode,hos.getName(),hos.getAppId(), hos.getAppSecret(), chargeType,chargeRelation,totalAmount, selfpayAmount, insuranceAmount, feeDetail,patient,openid);
    }
    /**
     * 家庭医生签约支付
     * 家庭医生签约支付,成功则返回支付路径
     */
    public String charge(String appId,String appSecret,String code,String date,String cardNo,String openid) throws Exception
    private String charge(String orgCode,String orgName,String appId,String appSecret,String chargeType,String chargeRelation,Integer totalAmount,Integer selfpayAmount,Integer insuranceAmount,String feeDetail,String patient,String openid) throws Exception
    {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = "";
        String channel = "WX_MMP";   //  医保支付渠道
        String subject = "家庭医生签约支付";   //  订单名称
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(),appId, appSecret, signType, encryptType);
        WlyyCharge charge = new WlyyCharge();
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        charge.setChargeType(chargeType);   //交易类型
        charge.setChargeRelation(chargeRelation);  //交易关联代码
        charge.setCode(uuid);  //  接入应用支付业务流水号
        Date now = new Date();
        charge.setCreateTime(now);
        charge.setPatient(patient);     //  用户
        charge.setOpenid(openid);     //  用戶微信openid
        try {
            BindCard card= bindCard(openid);
            String name = card.getUserName();
            String ssc = card.getCardNo();
            String idType = card.getIdType();
            String idNo = card.getIdNo();
            charge.setName(name);
            charge.setIdType(idType);
            charge.setIdNo(idNo);
            charge.setHospital(orgCode);
            charge.setHospitalName(orgName);
            charge.setChannel(channel);
            charge.setMerchName(orgName);
            charge.setSubject(subject);
            charge.setTotalAmount(totalAmount);  //  交易总金额
            charge.setSelfpayAmount(selfpayAmount);  //  自费金额
            charge.setInsuranceAmount(insuranceAmount);  //  医保支付金额
            charge.setFeeDetail(feeDetail);  //  费用明细
            SimpleDateFormat formatter =   new SimpleDateFormat("yyyyMMddHHmmss");
            String currentDateTime = formatter.format(now);
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setTimestamp(currentDateTime);
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setTransType(config.getChargeType());
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outSettleNo",code);  //接入应用结算业务流水号
            params.put("outSettleTime",date);    //接入应用内结算时间
            params.put("outChargeNo",uuid);  //接入应用结算业务流水号
            params.put("outChargeTime",currentDateTime);    //接入应用内结算时间
            params.put("userId",openid);   //用户 ID
            params.put("cardNo",cardNo);   //医保卡号"D64775061"
            params.put("totalAmount","1");   //交易总金额
            params.put("selfpayAmount","0");   //自费金额
            params.put("insuranceAmount","1");   //医保支付金额
            params.put("returnUrl","http://");   //页面跳转地址
            params.put("feeDetail","{\"itemName\":\"家庭医生签约支付\",\"itemDesc\":\"家庭医生签约支付\",\"itemOrigPrice\":\"120\",\"itemNowPrice\":\"120\",\"itemNum\":\"1\",\"itemTotalAmt\":\"120\"}");   //费用明细
            params.put("channel","WX_MMP");  //微信医保支付
            //extendParams 扩展入参
            //requestContent 请求结构体
            params.put("cardNo",ssc);   //医保卡号"D64775061"
            //获取绑卡信息
            params.put("userName",name);
            params.put("idType",idType);
            params.put("idNo",idNo);
            params.put("totalAmount",totalAmount);   //交易总金额
            params.put("selfpayAmount",selfpayAmount);   //自费金额
            params.put("insuranceAmount",insuranceAmount);   //医保支付金额
            params.put("returnUrl","https://mp.weixin.qq.com/insurance/pay/detail");   //页面跳转地址
            params.put("feeDetail",feeDetail);   //费用明细
            params.put("channel",channel);  //微信医保支付
            params.put("merchName",orgName);  //收款单位名称
            params.put("subject",subject);  //订单名称
            //params.put("wxToken","");
            //extendParams 扩展入参
            Map<String,String> map = new HashMap<>();
            map.put("feeType","04");//家庭医生签约
            map.put("settleType","02"); //健康账户支付
            params.put("requestContent",objectMapper.writeValueAsString(map));// 请求结构体
            requestParams.setParam(params);
            msgBody =  JSON.toJSONString(requestParams);
            //执行支付
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            msgBody =  JSON.toJSONString(requestParams);
            response =  JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                JSONObject json = res.getParam();
                result = String.valueOf(json.get("settleNo"));      //医保结算业务流水号
                String payUrl =  String.valueOf(json.get("payUrl"));
                //业务处理***********
                String chargeNo = String.valueOf(json.get("chargeNo"));      //医保结算业务流水号
                result =  String.valueOf(json.get("payUrl"));
                charge.setTradeStatus("0");//交易状态0 成功 1 失败 2 已退款
                charge.setChargeNo(chargeNo);
            } else {
                charge.setTradeStatus("1");
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
@ -180,6 +270,8 @@ public class OnePayService {
            error = sw.toString();
        }
        //保存交易记录
        chargeDao.save(charge);
        //保存http日志
        logService.saveHttpLog(isSuccess,config.getChargeType(),"家庭医生签约支付","POST",null,msgBody,response,error,logService.onepayType);
@ -217,12 +309,12 @@ public class OnePayService {
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outSettleNo",code);  //接入应用结算业务流水号
            params.put("settleNo","");
            params.put("outChargeNo",code);  //接入应用结算业务流水号
            requestParams.setParam(params);
            msgBody =  JSON.toJSONString(requestParams);
            //执行支付
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            msgBody =  JSON.toJSONString(requestParams);
            response =  JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
@ -244,7 +336,73 @@ public class OnePayService {
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,config.getChargeType(),"家庭医生签约支付","POST",null,msgBody,response,error,logService.onepayType);
        logService.saveHttpLog(isSuccess,config.getChargeType(),"家庭医生签约支付查询","POST",null,msgBody,response,error,logService.onepayType);
        if(!isSuccess)
        {
            throw new Exception(error);
        }
        return result;
    }
    /**
     * 生成电子社保卡
     */
    public String createSicard(String patient,String openid) throws Exception
    {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = "";
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(),appId, appSecret, signType, encryptType);
        try {
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            // 请求报文体参数,详见接口文档各接口——请求参数定义
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("userId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getCreateSicardType());
            msgBody =  JSON.toJSONString(requestParams);
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response =  JSON.toJSONString(res);
            // 如医保卡绑卡信息返回参数
            if (OnepayDefaultClient.isSuccessful(res)) {
                JSONObject json = res.getParam();
                result = String.valueOf(json.get("sicardUrl"));      //电子社保卡连接
                //保存到患者表
            }
            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();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,config.getBindCardType(),"生成电子社保卡","POST",null,msgBody,response,error,logService.onepayType);
        if(!isSuccess)
        {
@ -253,4 +411,62 @@ public class OnePayService {
        return result;
    }
    /**
     *更新所有记录的交易状态
     */
    private List<WlyyCharge> updateTradeStatus(List<WlyyCharge> list)
    {
        //更新交易状态
        if(list!=null &&list.size()>0)
        {
            for(WlyyCharge item:list)
            {
                try{
                    Charge charge = chargeQuery(item.getCode());
                    if(charge!=null)
                    {
                        item.setTradeStatus(charge.getTradeStatus());            //  交易状态0 成功 1 失败 2 已退款
                        item.setChargeNo(charge.getChargeNo());       //  流水号
                        item.setChargeTime(charge.getChargeTime());      // 扣费时间
                        item.setMedOrgNo(charge.getMedOrgNo()); // 医疗机构编码
                        item.setMedOrgName(charge.getMedOrgName());  //医疗机构名称
                        item.setBillNo(charge.getBillNo());  //待结算费用单据号
                    }
                }
                catch (Exception ex)
                {
                    System.out.print("update trade status fail!");
                }
            }
            chargeDao.save(list);
        }
        return list;
    }
    /**
     * 通过交易关联代码获取交易列表
     */
    public List<WlyyCharge> chargeList(String chargeType,String chargeRelation) throws Exception
    {
        List<WlyyCharge> list = chargeDao.findByChargeTypeAndChargeRelation(chargeType,chargeRelation);
        return updateTradeStatus(list);
    }
    /**
     * 通过患者代码获取交易列表
     */
    public List<WlyyCharge> chargeListByPatient(String patient, Integer page, Integer size) throws Exception
    {
        PageRequest pageRequest = new PageRequest(page - 1, size);
        List<WlyyCharge> list = chargeDao.findByPatient(patient,pageRequest);
        return updateTradeStatus(list);
    }
}

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

@ -1,9 +1,9 @@
package com.yihu.wlyy.task;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.wechat.WechatTemplate;
import com.yihu.wlyy.entity.wechat.WechatTemplateData;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SystemConf;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -14,13 +14,11 @@ import org.slf4j.LoggerFactory;
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.ResponseBody;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.wechat.WechatTemplate;
import com.yihu.wlyy.entity.wechat.WechatTemplateData;
import com.yihu.wlyy.util.HttpUtil;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
@Controller
@RequestMapping(value = "/pushMsgTask", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ -181,6 +179,7 @@ public class PushMsgTask {
     * 发送微信模板消息
     *
     * @param type 1:签约成功  2:签约失败  3:咨询回复通知  4:健康指导提醒  5:解约申请通知  6:预约挂号成功通知  7:预约取消通知 8 缴费提醒 9 健康教育  10 签约医生变更
     *             18 产检提醒和产检就诊提醒
     * @param json 当type==1||type==2时:{"first":"消息主题",”doctor":"医生code","doctorName":"医生名","date":"签约时间","content":"签约内容","remark":"消息备注"}
     *             type==3时:{"first":"消息主题","consult":"医生咨询编号","consultcontent":"咨询内容","replycontent":"回复内容","doctorName":"医生名","remark":"消息备注"}
     *             type==4时:{"first":"消息主题","date":"指导时间","orgName":"指导机构","doctorName":"指导医生名","content":"指导内容","remark":"消息备注"}
@ -561,6 +560,17 @@ public class PushMsgTask {
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            } else if (type == 18) {
                temp.setUrl(url + json.getString("url"));
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties().getProperty("template_doctor_survey"));
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
                WechatTemplateData keyword2 = new WechatTemplateData();
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }
            temp.setData(m);

+ 30 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -1,16 +1,11 @@
package com.yihu.wlyy.util;
import java.sql.Time;
import org.apache.commons.lang3.StringUtils;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
public class DateUtil {
@ -826,4 +821,31 @@ public class DateUtil {
		}
		return getNowYear()-1;
	}
	/**
	 * 计算预产期
	 * 末次月经开始日期(第一天),月份+9,日期+7
	 * @param date
	 * @return
	 */
	public static Date getDueDate(Date date){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.MONTH,9);
		cal.add(Calendar.DAY_OF_YEAR,7);
		return cal.getTime();
	}
	/**
	 * 计算产检时间
	 * @param date
	 * @param day
	 * @return
	 */
	public static Date getPrenatalInspectorDate(Date date,Integer day){
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.add(Calendar.DAY_OF_YEAR,day);
		return cal.getTime();
	}
}

+ 27 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ImUtill.java

@ -3,17 +3,12 @@ package com.yihu.wlyy.util;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by 卓 on 2017/1/13.
 */
public class ImUtill {
    
    private static final String im_host = SystemConf.getInstance().getImListGet();
    private static final String im_host = SystemConf.getInstance().getImListGet();
    /**
     * 获取医生统计数据
@ -124,14 +119,34 @@ public class ImUtill {
     * @param contentType 1文字 2图片消息
     * @param content     内容
     */
    public static String sendTopicIM(String from,String fromName, String topicId, String contentType, String content) {
    public static String sendTopicIM(String from,String fromName, String topicId, String contentType, String content,String agent) {
        String url = im_host + "api/v2/sessions/topic/"+topicId+"/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("topic_id", topicId);;
        params.put("topic_id", topicId);
        params.put("agent", agent);
        String response = HttpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 发送进入im消息
     * @param from
     * @param sessionId
     * @param topicId
     * @return
     */
    public static String sendIntoTopicIM(String from,String sessionId,String topicId,String content,String intoUser,String intoUserName){
        String url = im_host + "api/v2/sessions/"+sessionId+"/topics/"+topicId+"/into";
        JSONObject params = new JSONObject();
        params.put("sender_id", from);
        params.put("topic_id", topicId);
        params.put("into_user", intoUser);
        params.put("into_user_name", intoUserName);
        params.put("content", content);
        String response = HttpClientUtil.postBody(url, params);
        return response;
    }
@ -228,15 +243,17 @@ public class ImUtill {
     * @param title
     * @param description
     * @param images
     * @param agent
     * @return
     */
    public static JSONObject getCreateTopicMessage(String senderId,String senderName,String title,String description,String images){
    public static JSONObject getCreateTopicMessage(String senderId,String senderName,String title,String description,String images,String agent){
        JSONObject messages = new JSONObject();
        messages.put("description",description);
        messages.put("title",title);
        messages.put("img",images);
        messages.put("sender_id",senderId);
        messages.put("sender_name",senderName);
        messages.put("agent",agent);
        return messages;
    }
@ -291,7 +308,7 @@ public class ImUtill {
                return obj;
            }
        }catch (Exception e){
           throw new RuntimeException("人员更换失败!");
            throw new RuntimeException("人员更换失败!");
        }
    }
@ -356,5 +373,4 @@ public class ImUtill {
    public  static final String SESSION_STATUS_END= "1";
    public  static final String CONTENT_TYPE_TEXT= "1";
}

+ 5 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemConf.java

@ -376,5 +376,9 @@ public class SystemConf {
	}
	/**************************************************************************************/
	/**
	 * 获取IM数据库名
	 * @return
     */
	public String getImDataBaseName(){ return getSystemProperties().getProperty("im_dataBase");}
}

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

@ -1,9 +1,6 @@
package com.yihu.wlyy.web.common.util;
import com.yihu.wlyy.job.QuartzHelper;
import com.yihu.wlyy.job.RenewToSignJob;
import com.yihu.wlyy.job.SignAgainJob;
import com.yihu.wlyy.job.SignEndJob;
import com.yihu.wlyy.job.*;
import com.yihu.wlyy.job.consult.EvaluateScoreJob;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
@ -14,25 +11,18 @@ import com.yihu.wlyy.service.common.util.ManageUtilService;
import com.yihu.wlyy.service.common.util.SignTeamAndGroupRunnable;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.hash.HashMapper;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.security.Signature;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
/**
 * Created by lyr on 2016/09/13.
@ -333,4 +323,24 @@ public class ManagerUtilController extends BaseController {
            return error(-1, "启动失败");
        }
    }
    /**
     * 产检提醒
     *  每天早上六点
     * @return
     */
    @RequestMapping(value = "/start_prenatal_inspector_job")
    @ResponseBody
    public String startPrenatalInspectorJob() {
        try {
            if (!quartzHelper.isExistJob("prenatal_inspector_job")) {
                quartzHelper.addJob(PrenatalInspectorJob.class, "0 0 6 * * ?", "prenatal_inspector_job", new HashMap<String, Object>());
                return write(200, "启动成功");
            } else {
                return write(200, "任务已存在");
            }
        } catch (Exception e) {
            return error(-1, "启动失败");
        }
    }
}

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

@ -1,18 +1,22 @@
package com.yihu.wlyy.web.doctor.consult;
import java.util.List;
import java.util.Map;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamLog;
import com.yihu.wlyy.entity.discussion.WlyyTalkGroup;
import com.yihu.wlyy.entity.discussion.WlyyTalkGroupMember;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -21,7 +25,6 @@ import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -29,15 +32,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
import java.util.List;
import java.util.Map;
/**
 * 医生端:三师咨询控制类
@ -680,7 +676,7 @@ public class DoctorConsultController extends WeixinBaseController {
            consult.setVoice(voice);
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            JSONObject result = consultTeamService.famousConsult(consult, getUID(), "2");
            JSONObject result = consultTeamService.famousConsult(consult, getUID(), "2",null);
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.D_CT_04.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), consult.getConsult());
            if (StringUtils.isNotEmpty(images)) {

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

@ -260,7 +260,7 @@ public class SignPatientLabelInfoController extends BaseController {
                return write(200, "查询成功", "data", r);
            }
            if(labelType.equals("1")){
            if(labelType.equals("1")&&teamCode!=0L){
                JSONArray r= patientService.getSignByDoctorCodeGpbyServer(getUID(),teamCode+"");
                return write(200, "查询成功", "data", r);
            }

+ 13 - 15
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -1,10 +1,7 @@
package com.yihu.wlyy.web.patient.account;
import com.sun.org.apache.regexp.internal.RE;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.security.Token;
@ -24,10 +21,8 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -77,9 +72,12 @@ public class PatientController extends WeixinBaseController {
    @ResponseBody
    public String baseinfo() {
        try {
            Patient temp = patientInfoService.findByCode(getUID());
            SignFamily sanshi = familyContractService.findByPatientByType(getUID(), 1);
            SignFamily jiating = familyContractService.findByPatientByType(getUID(), 2);
//            Patient temp = patientInfoService.findByCode(getUID());
//            SignFamily sanshi = familyContractService.findByPatientByType(getUID(), 1);
//            SignFamily jiating = familyContractService.findByPatientByType(getUID(), 2);
            Patient temp = patientInfoService.findByCode(getRepUID());
            SignFamily sanshi = familyContractService.findByPatientByType(getRepUID(), 1);
            SignFamily jiating = familyContractService.findByPatientByType(getRepUID(), 2);
            int sign = 0;
            if (sanshi != null && jiating != null) {
                sign = 3;
@ -502,11 +500,11 @@ public class PatientController extends WeixinBaseController {
            Map<String, String> teamDoctors = new HashMap<>();
            Map<String, String> familyDoctors = new HashMap<>();
            Map<String,String> signDoctors = new HashMap<>();
            String id = getUID();
            String id = getRepUID();
//            String id = getUID();
            JSONObject json = new JSONObject();
            //查询家庭签约
            SignFamily jt = familyContractService.findByPatientYes(id);
            if (jt != null) {
                List<Doctor> doctors = doctorTeamService.findJiatingTeamDoctors(id);
                if (doctors != null) {
@ -523,7 +521,6 @@ public class PatientController extends WeixinBaseController {
                if(StringUtils.isNotBlank(jt.getDoctorHealth())&&StringUtils.isNotBlank(jt.getDoctorHealthName())){
                    signDoctors.put(jt.getDoctorHealth(), jt.getDoctorHealthName());
                }
            }
            // 查询三师医生
            SignFamily ss = familyContractService.findBySanshiPatientYes(id);
@ -538,7 +535,7 @@ public class PatientController extends WeixinBaseController {
                    }
                }
                json.put("teamCode_"+1,ss.getTeamCode());
                json.put("signCode_"+1,jt.getCode());
                json.put("signCode_"+1,ss.getCode());
            }
            // 未签约
            int sign = 0;
@ -577,7 +574,8 @@ public class PatientController extends WeixinBaseController {
        try {
            List<JSONObject> teamDoctors = new ArrayList<>();
            List<JSONObject> familyDoctors = new ArrayList<>();
            String id = getUID();
            String id = getRepUID();
//            String id = getUID();
            //查询家庭签约
            SignFamily jt = familyContractService.findByPatientYes(id);
            if (jt != null) {
@ -670,12 +668,12 @@ public class PatientController extends WeixinBaseController {
        try {
            JSONObject jsonObject = new JSONObject();
            //判断是否有三师签约
            SignFamily ss = familyContractService.findBySanshiPatient(getUID());  // -1 未签约  0 待签约 1 已签约 2待解约
            SignFamily ss = familyContractService.findBySanshiPatient(getRepUID());  // -1 未签约  0 待签约 1 已签约 2待解约
            if (ss != null) {
                return write(200, "获取签约状态成功!", "data", ss.getStatus());
            }
            //判断是否有家庭签约
            SignFamily sf = familyContractService.findByFamilySignPatient(getUID());
            SignFamily sf = familyContractService.findByFamilySignPatient(getRepUID());
            if (sf != null) {
                return write(200, "获取签约状态成功!", "data", sf.getStatus());
            }

+ 8 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java

@ -9,12 +9,10 @@ import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
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;
@ -24,14 +22,8 @@ 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.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -67,7 +59,8 @@ public class PatientArchivesController extends WeixinBaseController {
                              @ApiParam(name="lastTime",value="最后一条时间",defaultValue = "2010-10-10 00:00:00")
                              @RequestParam(value="lastTime",required = false) String lastTime) {
        try {
            List<Map<String,String>> result = patientRecordService.getAllEvent(getUID(),type,page,pageSize,lastTime);
            List<Map<String,String>> result = patientRecordService.getAllEvent(getRepUID(),type,page,pageSize,lastTime);
            return write(200, "获取就诊记录成功!", "data", result);
        } catch (Exception e) {
@ -95,7 +88,8 @@ public class PatientArchivesController extends WeixinBaseController {
                                @ApiParam(name="serial",value="该类别顺序号,默认填1",defaultValue = "1")
                                @RequestParam(value="serial",required = true) String serial) {
        try {
            String result = patientRecordService.getHealthData(getUID(), event, catalog, serial);
            String result = patientRecordService.getHealthData(getRepUID(), event, catalog, serial);
//            String result = patientRecordService.getHealthData(getUID(), event, catalog, serial);
            return write(200, "获取健康档案详情成功!", "data", result);
        } catch (Exception e) {
@ -175,7 +169,8 @@ public class PatientArchivesController extends WeixinBaseController {
                                    @RequestParam(value="lastTime",required = false) String lastTime)
    {
        try {
            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(getUID(), page, pageSize,lastTime);
            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(getRepUID(), page, pageSize,lastTime);
//            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(getUID(), page, pageSize,lastTime);
            return write(200, "获取检查检验报告成功!", "data", result);
        } catch (Exception e) {
@ -203,7 +198,8 @@ public class PatientArchivesController extends WeixinBaseController {
                          @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
                          @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try{
            Patient p = patientService.findByCode(getUID());
            Patient p = patientService.findByCode(getRepUID());
//            Patient p = patientService.findByCode(getUID());
            if(p != null){
                JSONArray re = jwArchivesService.getEhrSickMedicalList(p.getIdcard(),pageIndex,pageSize);
                return write(200,"查询成功","list",re);

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

@ -1,29 +1,28 @@
package com.yihu.wlyy.web.patient.consult;
import java.util.*;
import com.thoughtworks.xstream.mapper.Mapper;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamLog;
import com.yihu.wlyy.entity.discussion.WlyyTalkGroup;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkTime;
import com.yihu.wlyy.entity.doctor.schedule.WlyyDoctorWorkWeek;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.consult.DoctorCommentService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.DoctorStatisticsService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.DoctorStatisticsTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.listener.Topic;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -31,14 +30,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.consult.DoctorCommentService;
import com.yihu.wlyy.service.app.statistics.DoctorStatisticsService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.DoctorStatisticsTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 患者端:三师咨询控制类
@ -81,7 +75,7 @@ public class ConsultController extends WeixinBaseController {
            int pagesize) {
        try {
            JSONArray array = new JSONArray();
            Page<Object> data = consultTeamService.findConsultRecordByPatient(getUID(), id, pagesize, title);
            Page<Object> data = consultTeamService.findConsultRecordByPatient(getRepUID(), id, pagesize, title);
            if (data != null) {
                for (Object consult : data.getContent()) {
                    if (consult == null) {
@ -221,7 +215,8 @@ public class ConsultController extends WeixinBaseController {
    @ResponseBody
    public String getUnFinishedConsult() {
        try {
            List<ConsultTeam> unfinishedConsult = consultTeamService.getUnfinishedConsult(getUID());
//            List<ConsultTeam> unfinishedConsult = consultTeamService.getUnfinishedConsult(getUID());
            List<ConsultTeam> unfinishedConsult = consultTeamService.getUnfinishedConsult(getRepUID());
            JSONArray result = new JSONArray(unfinishedConsult);
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
@ -241,7 +236,7 @@ public class ConsultController extends WeixinBaseController {
    public String isExistsUnfinishedConsult(@RequestParam(required = true) String doctor) {
        try {
            JSONObject result = new JSONObject();
            List<ConsultTeam> consults = consultTeamService.getUnfinishedConsult(getUID(), doctor);
            List<ConsultTeam> consults = consultTeamService.getUnfinishedConsult(getRepUID(), doctor);
            if (consults != null && consults.size() > 0) {
                return write(200, "查询成功", "data", consults.get(0).getConsult());
@ -282,7 +277,7 @@ public class ConsultController extends WeixinBaseController {
                return error(-1, "无效请求!");
            }
            try {
                if (consultTeamService.exist(getUID(), type)) {
                if (consultTeamService.exist(getRepUID(), type)) {
                    return error(-1, "还有咨询未结束,不允许再次提交咨询!");
                }
            } catch (Exception e) {
@ -319,7 +314,7 @@ public class ConsultController extends WeixinBaseController {
            System.out.println("guidance2="+guidance);
            // 保存到数据库
            int res = consultTeamService.addTeamConsult(consult, getUID());
            int res = consultTeamService.addTeamConsult(consult, getRepUID(),getUID());
            if (res == -1) {
                return error(-1, "家庭签约信息不存在或已过期,无法进行家庭医生咨询!");
            } else if (res == -2) {
@ -340,7 +335,7 @@ public class ConsultController extends WeixinBaseController {
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getUID(), new JSONObject(consult));
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);
        } catch (Exception ex) {
            error(ex);
@ -348,6 +343,26 @@ public class ConsultController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "intoTopic",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("进入咨询")
    public String intoTopic(@RequestParam(required = true) String consult){
        try{
            int result = consultTeamService.intoTopic(consult,getRepUID(),getUID());
            if(result==-1){
                return error(-1,"该咨询不是进行中");
            }
            JSONObject json = new JSONObject();
            json.put("consult",consult);
            json.put("content","进入咨询");
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getRepUID(), json);
            return success("进入成功");
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    /**
     * 名医咨询添加接口
     *
@ -391,7 +406,7 @@ public class ConsultController extends WeixinBaseController {
                voice = CommonUtil.copyTempVoice(voice);
            }
            //判断是否已经存在还没有关闭的咨询
            if (consultTeamService.isExistConsult(getUID(), doctorCode)) {
            if (consultTeamService.isExistConsult(getRepUID(), doctorCode)) {
                return error(-1, "还有咨询未结束,不允许再次提交咨询!");
            }
            ConsultTeam consult = new ConsultTeam();
@ -407,14 +422,14 @@ public class ConsultController extends WeixinBaseController {
            consult.setVoice(voice);
            consult.setDoctor(doctorCode);//设置专科医生
            // 保存到数据库
            JSONObject object  = consultTeamService.famousConsult(consult, getUID(), "1");
            JSONObject object  = consultTeamService.famousConsult(consult, getRepUID(), "1",getUID());
            JSONObject resultConsult =  new JSONObject(consult);
            resultConsult.put("session_id",object.getString("session_id"));
            //名医咨询次数减一
            doctorWorkTimeService.setDoctorCurrentConsultTimesRemain(doctorCode);
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_03.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getUID(), getUID(), new JSONObject(consult));
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", resultConsult);
        } catch (Exception ex) {
            error(ex);
@ -516,7 +531,7 @@ public class ConsultController extends WeixinBaseController {
    @ResponseBody
    public String list(int status, long id, int pagesize) {
        try {
            Page<ConsultTeam> consults = consultTeamService.findByPatient(getUID(), status, id, pagesize);
            Page<ConsultTeam> consults = consultTeamService.findByPatient(getRepUID(), status, id, pagesize);
            JSONArray jsonArray = new JSONArray();
            if (consults != null) {
                for (ConsultTeam consult : consults) {
@ -585,7 +600,7 @@ public class ConsultController extends WeixinBaseController {
    @ResponseBody
    public String finish(@RequestParam(required = true) String code) {
        try {
            int row = consultTeamService.finishConsult(code, getUID(), 1);
            int row = consultTeamService.finishConsult(code, getRepUID(), 1);
            if (row > 0) {
                return success("操作成功!");
            } else {
@ -670,12 +685,15 @@ public class ConsultController extends WeixinBaseController {
                arr = new String[]{content};
            }
            Patient patient = patientDao.findByCode(getUID());
//            Patient patient = patientDao.findByCode(getUID());
            Patient patient = patientDao.findByCode(getRepUID());
            int i = 0;
            List<String> failed = new ArrayList<>();
            String agent = getUID()==getRepUID()?null:getUID();
            for (ConsultTeamLog log : logs) {
                String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
//                String response = ImUtill.sendTopicIM(getUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent());
                String response = ImUtill.sendTopicIM(getRepUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),agent);
                if (StringUtils.isNotEmpty(response)) {
                    JSONObject resObj = new JSONObject(response);
                    if (resObj.getInt("status") == -1) {
@ -707,10 +725,10 @@ public class ConsultController extends WeixinBaseController {
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            JSONObject messageObj = ImUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getUID());
            JSONObject messageObj = ImUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
            //过滤续签
            consultTeamService.removeRenewPerson(messageObj,getUID());
            consultTeamService.removeRenewPerson(messageObj,getRepUID());
            return write(200, "查询成功", "list", messageObj);
        } catch (Exception e) {
@ -729,7 +747,7 @@ public class ConsultController extends WeixinBaseController {
    @ResponseBody
    public String logs(@RequestParam String sessionId,@RequestParam(required = false) String startMsgId,@RequestParam(required = false) String endMsgId, @RequestParam int page, @RequestParam int pagesize) {
        try {
            JSONArray messageArray = ImUtill.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getUID());
            JSONArray messageArray = ImUtill.getSessionMessage(sessionId, startMsgId, endMsgId, page, pagesize, getRepUID());
            return write(200, "查询成功", "list", messageArray);
        } catch (Exception e) {
            error(e);
@ -744,7 +762,7 @@ public class ConsultController extends WeixinBaseController {
            JSONArray participants = ImUtill.getSessions(sessionId);
            //过滤续签
            consultTeamService.removeRenewPerson(participants,getUID());
            consultTeamService.removeRenewPerson(participants,getRepUID());
            return write(200, "查询成功", "list", participants);
        } catch (Exception e) {
@ -786,7 +804,7 @@ public class ConsultController extends WeixinBaseController {
            JSONObject json = new JSONObject();
            json.put("id", obj.getInt("id"));
            if (!obj.getString("from").equals(getUID())) {
            if (!obj.getString("from").equals(getRepUID())) {
                Doctor doc = doctorService.findDoctorByCode(obj.getString("from"));
                // 设置回复医生姓名
                json.put("doctorName", doc.getName());
@ -805,7 +823,7 @@ public class ConsultController extends WeixinBaseController {
            // 设置记录类型:1文字,2图片,3语音
            json.put("msgType", obj.getInt("contentType"));
            // 设置类型:0患者问,1医生回复,2患者追问,3患者评价
            if (!obj.getString("from").equals(getUID())) {
            if (!obj.getString("from").equals(getRepUID())) {
                json.put("type", 1);
            } else {
                json.put("type", obj.getInt("contentType") == 6 ? 0 : 2);
@ -832,7 +850,7 @@ public class ConsultController extends WeixinBaseController {
    public String comment(String consult, String content, int star) {
        try {
            // 保存评价
            JSONArray array = doctorCommentService.consultComment(getUID(), consult, content, star, 2);
            JSONArray array = doctorCommentService.consultComment(getRepUID(), consult, content, star, 2);
            // 添加到统计队列
            if (array != null) {
                DoctorStatisticsTask.getInstance(doctorStatisticsService).put(array);
@ -844,7 +862,7 @@ public class ConsultController extends WeixinBaseController {
            log.setChatType(1);
            log.setDel("1");
            log.setType(3);
            log = consultTeamService.reply(log, getUID(), null, log.getType());
            log = consultTeamService.reply(log, getRepUID(), null, log.getType());
            return success("感谢您的评价!");
        } catch (Exception e) {
            error(e);

+ 19 - 15
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultPublicController.java

@ -1,9 +1,13 @@
package com.yihu.wlyy.web.patient.consult;
import java.util.Date;
import com.yihu.wlyy.entity.consult.ConsultPublic;
import com.yihu.wlyy.entity.consult.ConsultPublicReply;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.consult.ConsultPublicService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -13,16 +17,10 @@ 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 com.yihu.wlyy.entity.consult.ConsultPublic;
import com.yihu.wlyy.entity.consult.ConsultPublicReply;
import com.yihu.wlyy.service.app.consult.ConsultPublicService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import java.util.Date;
/**
 * 患者端:图文咨询/公共咨询/病友圈控制类
@ -77,8 +75,10 @@ public class ConsultPublicController extends WeixinBaseController {
			}
			cp.setImages(images);
			// 设置患者标识
			cp.setPatient(getUID());
			Patient patient=patientInfoService.findByCode(getUID());
			cp.setPatient(getRepUID());
//			cp.setPatient(getUID());
//			Patient patient=patientInfoService.findByCode(getUID());
			Patient patient=patientInfoService.findByCode(getRepUID());
			cp.setSex(patient.getSex());
			// 设置问题标题
			cp.setTitle(question);
@ -113,7 +113,8 @@ public class ConsultPublicController extends WeixinBaseController {
	public String list(long id, int pagesize, @RequestParam(required = false) String disease) {
		try {
			JSONArray list = new JSONArray();
			Page<ConsultPublic> datas = consultPublicService.findPublicQuestionByPatient(getUID(), disease, id, pagesize);
			Page<ConsultPublic> datas = consultPublicService.findPublicQuestionByPatient(getRepUID(), disease, id, pagesize);
//			Page<ConsultPublic> datas = consultPublicService.findPublicQuestionByPatient(getUID(), disease, id, pagesize);
			if (datas != null) {
				for (ConsultPublic cp : datas) {
					if (cp == null) {
@ -180,8 +181,10 @@ public class ConsultPublicController extends WeixinBaseController {
				images = CommonUtil.copyTempImage(images);
			}
			reply.setImages(images);
			reply.setPatient(getUID());
			Patient patient=patientInfoService.findByCode(getUID());
//			reply.setPatient(getUID());
//			Patient patient=patientInfoService.findByCode(getUID());
			reply.setPatient(getRepUID());
			Patient patient=patientInfoService.findByCode(getRepUID());
			reply.setSex(patient.getSex());
			ConsultPublicReply temp = consultPublicService.addPatientReply(reply);
			if (temp == null) {
@ -232,7 +235,8 @@ public class ConsultPublicController extends WeixinBaseController {
			}
			if (id <= 0) {
				ConsultPublic temp = consultPublicService.findByConsult(consult);
				if (temp != null && StringUtils.equals(temp.getPatient(), getUID())) {
//				if (temp != null && StringUtils.equals(temp.getPatient(), getUID())) {
				if (temp != null && StringUtils.equals(temp.getPatient(), getRepUID())) {
					// 自己的帖子,清空未读数量
					consultPublicService.clearUnread(consult);
				}

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

@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -172,7 +171,8 @@ public class PatientDeviceController extends BaseController {
                                     @ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
                                     @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            Page<PatientDevice> list = patientDeviceService.findByPatient(getUID(), id, pagesize);
//            Page<PatientDevice> list = patientDeviceService.findByPatient(getUID(), id, pagesize);
            Page<PatientDevice> list = patientDeviceService.findByPatient(getRepUID(), id, pagesize);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {

+ 60 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -1,11 +1,12 @@
package com.yihu.wlyy.web.patient.family;
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.web.WeixinBaseController;
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;
@ -27,6 +28,8 @@ public class FamilyMemberController extends WeixinBaseController {
    @Autowired
    FamilyMemberService familyMemberService;
    @Autowired
    PatientFamilyMemberDao familyMemberDao;
    /**
     * 添加成员
@ -138,9 +141,28 @@ public class FamilyMemberController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/member_authorize", method = RequestMethod.POST)
    @ApiOperation(value = "家庭成员授权")
    public String authorizeMember(@ApiParam(name = "familyMember", value = "家人code", defaultValue ="1555c32c626343e7aaa62e9cf76c97f2")
                                  @RequestParam(value = "familyMember", required = true) String familyMember,
                                  @ApiParam(name = "isAuthorize", value = "是否授权(0:未授权,1:已授权)", defaultValue ="1")
                                  @RequestParam(value = "isAuthorize", required = true) Integer isAuthorize){
        try {
            int result = familyMemberService.authorizeMember(getUID(),familyMember,isAuthorize);
            if(result==0){
                return error(-1, "与该成员的关系不存在");
            }
            return write(200, "授权成功");
        }catch (Exception e){
            return error(-1,"授权失败");
        }
    }
    /**
     * 家庭成员查询
     *
     * @param patient
     * @return
     */
    @RequestMapping(value = "/members", method = RequestMethod.GET)
@ -150,7 +172,7 @@ public class FamilyMemberController extends WeixinBaseController {
            JSONArray result = new JSONArray();
            if (StringUtils.isNotEmpty(patient)) {
                result = familyMemberService.getPatientMembers(patient, "", true, getUID());
            } else {
            } else  {
                result = familyMemberService.getPatientFamilyMembers(getUID(), "");
            }
            return write(200, "查询成功", "data", result);
@ -160,6 +182,41 @@ public class FamilyMemberController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "/authorize_members", method = RequestMethod.GET)
    @ApiOperation(value = "家庭成员(有授权)查询")
    public String getAuthorizeFamilyMembers(){
        try {
            JSONArray result = familyMemberService.getAuthorizeMembers(getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/is_authorize", method = RequestMethod.GET)
    @ApiOperation(value = "是否授权查询")
    public String isAuthorize(@ApiParam(name = "patient", value = "居民code", defaultValue = "")
                              @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "familyMember", value = "家人code", defaultValue = "")
                              @RequestParam(value = "familyMember", required = true) String familyMember){
        try {
            if(patient.equals(familyMember)){
                return success("查询成功");
            }
            JSONObject json = familyMemberService.isAuthorize(patient,familyMember);
            if(json==null){
                return error(-1,"未授权");
            }
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 根据身份证号查询居民是否注册
     *

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

@ -63,7 +63,8 @@ public class PatientHealthController extends BaseController {
    public String getRecentData() {
        try {
            List list = new ArrayList();
            String patient = getUID();
            String patient = getRepUID();
//            String patient = getUID();
//            健康指标类型(1血糖,2血压,3体重,4腰围)
            Map map = healthIndexService.findDataByPatient(patient, 1);
            Map map1 = healthIndexService.findDataByPatient(patient, 2);
@ -242,7 +243,8 @@ public class PatientHealthController extends BaseController {
    @ApiOperation("患者最近填写的健康指标")
    public String recent() {
        try {
            JSONArray array = healthIndexService.findRecentByPatient(getUID());
            JSONArray array = healthIndexService.findRecentByPatient(getRepUID());
//            JSONArray array = healthIndexService.findRecentByPatient(getUID());
            if (array != null) {
                return write(200, "查询成功", "list", array);
            } else {
@ -261,7 +263,8 @@ public class PatientHealthController extends BaseController {
    public String last() {
        try {
            Map<String, Object> map = new HashMap<>();
            String patient = getUID();
            String patient = getRepUID();
//            String patient = getUID();
            DevicePatientHealthIndex xt = healthIndexService.findLastByPatien(patient, 1);
            if (xt != null) {
                map.put("xt", xt);
@ -381,9 +384,12 @@ public class PatientHealthController extends BaseController {
    public String addPatientHealthIndex(@ApiParam(name = "data", value = "指标数据", defaultValue = "{\"gi\":\"5.5\",\"gi_type\":\"1\"}")
                                        @RequestParam(value = "data", required = true) String data,
                                        @ApiParam(name = "type", value = "指标类型", defaultValue = "1")
                                        @RequestParam(value = "type", required = true) String type) {
                                        @RequestParam(value = "type", required = true) String type,
                                        @ApiParam(name = "patient", value = "居民code", defaultValue = "1")
                                        @RequestParam(value = "patient", required = true) String patient) {
        try {
            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
//            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, getUID(), null);
            DevicePatientHealthIndex obj = healthIndexService.addPatientHealthIndex(data, type, patient, null);
            //血糖和血压需要校验
            if (type.equals("1") || type.equals("2")) {
                healthIndexService.verifyHealthIndex(obj.getId());
@ -423,7 +429,8 @@ public class PatientHealthController extends BaseController {
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            List<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
            List<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
//            List<DevicePatientHealthIndex> list = healthIndexService.findChartByPatient(getUID(), type, gi_type, begin, end);
            if (list == null) {
                return success("查询成功!");
@ -472,10 +479,12 @@ public class PatientHealthController extends BaseController {
        try {
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
                List<Object> list = healthIndexService.findIndexByPatient2(getRepUID(), type, start, end, page, pagesize);
//                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
                jsonArray = new JSONArray(list);
            } else {
                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, start, end, page, pagesize);
                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
//                List<DevicePatientHealthIndex> list = healthIndexService.findIndexByPatient(getUID(), type, start, end, page, pagesize);
                if (list != null) {
                    for (DevicePatientHealthIndex model : list) {
                        JSONObject modelJson = new JSONObject();
@ -518,7 +527,8 @@ public class PatientHealthController extends BaseController {
        try {
            JSONArray standardArray = new JSONArray();
            JSONArray userArray = new JSONArray();
            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(getUID());
            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(getRepUID());
//            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(getUID());
            Iterator<PatientHealthStandard> iterator = null;
            if (iterable != null) {
                iterator = iterable.iterator();

+ 28 - 22
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/PatientHealthRecordController.java

@ -1,8 +1,17 @@
package com.yihu.wlyy.web.patient.health;
import java.util.Date;
import java.util.List;
import com.yihu.wlyy.entity.dict.Medicines;
import com.yihu.wlyy.entity.education.Sports;
import com.yihu.wlyy.entity.education.SportsType;
import com.yihu.wlyy.entity.patient.PatientHealthRecordDiet;
import com.yihu.wlyy.entity.patient.PatientHealthRecordMedication;
import com.yihu.wlyy.entity.patient.PatientHealthRecordSports;
import com.yihu.wlyy.service.app.health.PatientHealthRecordService;
import com.yihu.wlyy.service.app.medicines.MedicinesService;
import com.yihu.wlyy.service.app.sports.SportsService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -16,18 +25,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.dict.Medicines;
import com.yihu.wlyy.entity.patient.PatientHealthRecordDiet;
import com.yihu.wlyy.entity.patient.PatientHealthRecordMedication;
import com.yihu.wlyy.entity.patient.PatientHealthRecordSports;
import com.yihu.wlyy.entity.education.Sports;
import com.yihu.wlyy.entity.education.SportsType;
import com.yihu.wlyy.service.app.health.PatientHealthRecordService;
import com.yihu.wlyy.service.app.medicines.MedicinesService;
import com.yihu.wlyy.service.app.sports.SportsService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import java.util.Date;
import java.util.List;
/**
 * 健康记录控制类
@ -177,7 +176,8 @@ public class PatientHealthRecordController extends WeixinBaseController {
			PatientHealthRecordSports record = new PatientHealthRecordSports();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getUID());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setSportsTime(sportsTime);
@ -206,7 +206,8 @@ public class PatientHealthRecordController extends WeixinBaseController {
			PatientHealthRecordMedication record = new PatientHealthRecordMedication();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getUID());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setMedicines(medicines);
@ -236,7 +237,8 @@ public class PatientHealthRecordController extends WeixinBaseController {
			PatientHealthRecordDiet record = new PatientHealthRecordDiet();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getUID());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setContent(content);
@ -267,7 +269,8 @@ public class PatientHealthRecordController extends WeixinBaseController {
	@ResponseBody
	public String recent() {
		try {
			JSONObject json = patientHealthRecordService.findRecentByPatient(getUID());
//			JSONObject json = patientHealthRecordService.findRecentByPatient(getUID());
			JSONObject json = patientHealthRecordService.findRecentByPatient(getRepUID());
			if (json != null) {
				return write(200, "查询成功", "data", json);
			} else {
@ -288,7 +291,8 @@ public class PatientHealthRecordController extends WeixinBaseController {
	@ResponseBody
	public String sports(String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(getUID(), start,end,page, pagesize);
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(getRepUID(), start,end,page, pagesize);
//			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(getUID(), start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordSports record : data) {
@ -329,7 +333,8 @@ public class PatientHealthRecordController extends WeixinBaseController {
	@ResponseBody
	public String medication(String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(getUID(), start, end, page, pagesize);
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(getRepUID(), start, end, page, pagesize);
//			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(getUID(), start, end, page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordMedication record : data) {
@ -366,7 +371,8 @@ public class PatientHealthRecordController extends WeixinBaseController {
	@ResponseBody
	public String diet(String start,String end,int page,int pagesize) {
		try {
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(getUID(),start,end,page, pagesize);
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(getRepUID(),start,end,page, pagesize);
//			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(getUID(),start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordDiet record : data) {

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 78 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/PrenatalInspectorContoller.java


+ 76 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -840,5 +840,81 @@ public class StatisticsController extends BaseController {
        }
    }
    /**
     * 获取团队月或周咨询未回复和总数折线图
     * @param teamCode 团队id
     * @param startDate
     * @param endDate
     * @param type 0周,1月
     * @return
     */
    @RequestMapping("/getTeamConsultCount")
    @ResponseBody
    public String getTeamConsultCount(String teamCode,String startDate,String endDate,String type){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamConsultCount(teamCode,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     *  计算团队医生月或周咨询未回复和总数折线图
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param type 0周,1月
     * @param doctor
     * @return
     */
    @RequestMapping("/getTeamDocotorConsultCount")
    @ResponseBody
    public String getTeamDocotorConsultCount(String teamCode,String startDate,String endDate,String type,String doctor){
        try {
            return write(200, "查询成功", "data", statisticsService.getTeamDocotorConsultCount(teamCode,startDate,endDate,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队内这成员,未回复数,总数,结束咨询数
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param sort 0降序,1升序
     * @return
     */
    @RequestMapping("/getMemberConsultList")
    @ResponseBody
    public String getMemberConsultList(String teamCode,String startDate,String endDate,String sort){
        try {
            return write(200, "查询成功", "data", statisticsService.getMemberConsultList(teamCode,startDate,endDate,sort));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取Doctor咨询结果
     * @param doctor
     * @param teamCode
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getDoctorConsultTitle")
    @ResponseBody
    public String getDoctorConsultTitle(String doctor,String teamCode,String startDate,String endDate){
        try {
            return write(200, "查询成功", "data", statisticsService.getDoctorConsultTitle(doctor,teamCode,startDate,endDate));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}

+ 161 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -1,9 +1,13 @@
package com.yihu.wlyy.web.wx;
import com.yihu.wlyy.entity.charge.WlyyCharge;
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;
import com.yihu.wlyy.web.WeixinBaseController;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -15,6 +19,14 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2017/05/23.
 */
@ -32,7 +44,7 @@ public class OnePayController extends WeixinBaseController {
    @ResponseBody
    public String bindCard() throws Exception {
        try {
            BindCard bindCard = pay.bindCard(getOpenid());         //oULM4xOARzTFqr9y1aTWuzCQdUL0
            BindCard bindCard = pay.bindCard("patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30      getUID()getOpenid()
            return write(200, "查询绑卡信息成功!","data",bindCard);
        }
        catch (Exception e)
@ -47,14 +59,20 @@ public class OnePayController extends WeixinBaseController {
    public String charge(
                         @ApiParam(name="orgCode",value="医疗机构编号",defaultValue = "3502050300")
                         @RequestParam String orgCode,
                         @ApiParam(name="code",value="签约代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
                         @RequestParam String code,
                         @ApiParam(name="date",value="签约付款时间yyyyMMddHHmmss",defaultValue = "20170523172400")
                         @RequestParam String date,
                         @ApiParam(name="cardNo",value="社保卡号",defaultValue = "DC0261911")
                         @RequestParam String cardNo) throws Exception {
                         @ApiParam(name="chargeType",value="支付类型",defaultValue = "1")
                         @RequestParam String chargeType,
                         @ApiParam(name="chargeRelation",value="支付关联代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
                         @RequestParam String chargeRelation,
                         @ApiParam(name="totalAmount",value="交易总金额(分)",defaultValue = "1")
                         @RequestParam Integer totalAmount,
                         @ApiParam(name="selfpayAmount",value="自费金额(分)",defaultValue = "0")
                         @RequestParam Integer selfpayAmount,
                         @ApiParam(name="insuranceAmount",value="医保支付金额(分)",defaultValue = "1")
                         @RequestParam Integer insuranceAmount,
                         @ApiParam(name="feeDetail",value="费用明细",defaultValue = "[{\"itemName\":\"家庭医生签约支付\",\"itemDesc\":\"家庭医生签约支付\",\"itemOrigPrice\":\"1\",\"itemNowPrice\":\"1\",\"itemNum\":\"1\",\"itemTotalAmt\":\"1\"}]")
                         @RequestParam String feeDetail) throws Exception {
        try {
            String settleNo = pay.charge(orgCode,code,date,cardNo,getOpenid());  //"oULM4xOARzTFqr9y1aTWuzCQdUL0"
            String settleNo = pay.charge(orgCode,chargeType,chargeRelation,totalAmount, selfpayAmount, insuranceAmount, feeDetail,"patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
            return write(200, "家庭医生签约支付成功!","data",settleNo);
        }
        catch (Exception e)
@ -67,7 +85,7 @@ public class OnePayController extends WeixinBaseController {
    @RequestMapping(value = "chargeQuery", method = RequestMethod.POST)
    @ApiOperation("家庭医生签约支付查询")
    @ResponseBody
    public String chargeQuery(@ApiParam(name="code",value="签约代码",defaultValue = "20170523172835")
    public String chargeQuery(@ApiParam(name="code",value="支付流水号",defaultValue = "")
                               @RequestParam String code) throws Exception {
        try {
            Charge charge = pay.chargeQuery(code);
@ -79,5 +97,139 @@ public class OnePayController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "createSicard", method = RequestMethod.POST)
    @ApiOperation("生成电子社保卡")
    @ResponseBody
    public String createSicard() throws Exception {
        try {
            String sicardUrl = pay.createSicard("patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30  getUID(),getOpenid()
            return write(200, "生成电子社保卡成功!","data",sicardUrl);
        }
        catch (Exception e)
        {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "chargeList", method = RequestMethod.POST)
    @ApiOperation("获取某次签约的支付记录")
    @ResponseBody
    public String chargeList(@ApiParam(name="chargeType",value="支付类型",defaultValue = "1")
                                  @RequestParam String chargeType,
                                  @ApiParam(name="chargeRelation",value="支付关联代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
                                  @RequestParam String chargeRelation) throws Exception {
        try {
            List<WlyyCharge> charge = pay.chargeList(chargeType,chargeRelation);
            return write(200, "获取某次签约的支付记录成功!","data",charge);
        }
        catch (Exception e)
        {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "chargeListByPatient", method = RequestMethod.POST)
    @ApiOperation("获取患者的支付记录")
    @ResponseBody
    public String chargeListByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "")
                             @RequestParam String patient,
                             @ApiParam(name="page",value="第几页,从1开始",defaultValue = "1")
                             @RequestParam Integer page,
                             @ApiParam(name="size",value="每页几行",defaultValue = "10")
                             @RequestParam Integer size) throws Exception {
        try {
            List<WlyyCharge> charge = pay.chargeListByPatient(patient,page,size);
            return write(200, "获取患者的支付记录成功!","data",charge);
        }
        catch (Exception e)
        {
            return error(-1, e.getMessage());
        }
    }
    /**
     * 解析URL参数串
     * @param formContext
     * @param wordFirstsplitRegex
     * @param wordSecondsplitRegex
     * @return
     */
    private static Map<String, String> resolveFormContext(String formContext, String wordFirstsplitRegex, String wordSecondsplitRegex) {
        if (StringUtil.isEmpty(formContext)) {
            return null;
        }
        Map<String, String> targetMap = new HashMap<String, String>();
        String[] wordSeconds = formContext.split(wordSecondsplitRegex);
        for (String wordSecond : wordSeconds) {
            if (StringUtil.isEmpty(wordSecond)) {
                continue;
            }
            int idx = wordSecond.indexOf(wordFirstsplitRegex);
            targetMap.put(wordSecond.substring(0, idx), wordSecond.substring(idx + 1, wordSecond.length()));
        }
        return targetMap;
    }
    /**
     * 转换URL参数中为Map
     * @param reqQueryString
     * @return
     * @throws PayException
     */
    private Map<String, String> getRequestMap(String reqQueryString) throws PayException {
        if (StringUtil.isEmpty(reqQueryString)) {
            throw new PayException("跳转参数为空");
        }
        Map<String, String> targetMap = null;
        try {
            reqQueryString = URLDecoder.decode(reqQueryString, "utf-8");
            targetMap = resolveFormContext(reqQueryString, "=", "&");
        } catch (Exception e) {
            throw new PayException("跳转参数处理异常," + reqQueryString);
        }
        return targetMap;
    }
    @RequestMapping(value = "/returnUrl", method = RequestMethod.GET)
    @ApiOperation("商户页面跳转(模拟测试)")
    public void testReturnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().write("返回结果:\n" + request.getQueryString() +"\n");
        String onepayUrl = request.getParameter("onepayUrl");
        String appId = "1BHEOI11C00J7B2CA8C0000071FA53E1";
        String appSecret = "1BHEOH8HB0006E0A0A0A00002DB28BC5";
        String signType = "MD5";
        String encryptType = "DES";
        try {
            OnepayDefaultClient client = new OnepayDefaultClient(onepayUrl, appId, appSecret, signType, encryptType);
            Map<String, String> returnParams = getRequestMap(request.getQueryString());
            /*boolean isVerify = client.verifyReturnSign(returnParams, returnParams.get("sign"));
            if (isVerify) {
                response.getWriter().write("签名结果:\nSIGN SUCCESS.\n");
                // TODO 继续处理业务
                //		如:查询显示订单信息
            } else {
                response.getWriter().write("签名结果:\nSIGN ERROR !!!\n");
            }*/
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
        }
    }
}

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

@ -70,9 +70,14 @@ sign_end_job_trigger= 0 0 0 1 7 ?
sign_again_job_trigger=59 59 23 7/7 * ?
# 续签提醒JOB停止时间
sign_again_job_end=2017-10-1 00:00:00
# 产检提醒JOB触发时间 (每天6点一次)
prenatal_inspector_job_trigger=0 0 6 * * ?
evaluate_score_job = 0 0 */2 * * ?
#im数据库名
im_dataBase = im_new
#-------------------------开发环境配置-------------------------#
## 服务器基本配置
#server_ip=weixin.xmtyw.cn