Преглед изворни кода

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

Conflicts:
	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/DoctorService.java
trick9191 пре 7 година
родитељ
комит
574d1e8922
84 измењених фајлова са 5650 додато и 2268 уклоњено
  1. 53 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/httpLog/HttpLogDetail.java
  2. 145 135
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlan.java
  3. 107 107
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlanLibrary.java
  4. 549 442
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPreCard.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  6. 2 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java
  7. 291 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrenatalInspectorController.java
  8. 14 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  9. 2 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/HttpLogDao.java
  10. 11 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/log/HttpLogDetailDao.java
  11. 2 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/ZyPushLogDao.java
  12. 11 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/log/ZyPushLogDetailDao.java
  13. 19 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prenatal/PrenatalInspectorPreCardDao.java
  14. 3 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java
  15. 1 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/HttpLog.java
  16. 52 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/log/HttpLogDetail.java
  17. 2 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/ZyPushLog.java
  18. 61 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/log/ZyPushLogDetail.java
  19. 550 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prenatal/PrenatalInspectorPreCard.java
  20. 2 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionLog.java
  21. 14 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/VO/PrescriptionExpressageVO.java
  22. 64 18
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/LogService.java
  23. 0 8
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/OpenCountService.java
  24. 21 9
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftBaseService.java
  25. 177 90
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftMaternalService.java
  26. 71 36
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  27. 115 7
      patient-co-service/wlyy_service/src/main/webapp/prescription_consulting/js/prescription_consulting_info.js
  28. 11 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/HttpLogDetailDao.java
  29. 53 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/entity/HttpLogDetail.java
  30. 24 6
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/LogService.java
  31. 8 0
      patient-co/patient-co-statistics-es/pom.xml
  32. 15 4
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/ElasticsearchUtil.java
  33. BIN
      patient-co/patient-co-statistics/doc/业务文档/统计指标流程.docx
  34. 1 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/QuartzJobLog.java
  35. 2 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java
  36. 9 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  37. 2 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionExecuteSickSettleJob.java
  38. 4 4
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SFExpressJob.java
  39. 36 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignFamilyPayResultJob.java
  40. 4 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java
  41. 3 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java
  42. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java
  43. 2 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  44. 234 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  45. 31 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  46. 1 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  47. 129 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java
  48. 2 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  49. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  50. 5 2
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  51. BIN
      patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx
  52. BIN
      patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美对外测试服务器信息.docx
  53. 12 0
      patient-co/patient-co-wlyy/pom.xml
  54. 93 93
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java
  55. 49 49
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java
  56. 1 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/EncodingFilter.java
  57. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/httplog/HttpLogDetailDao.java
  58. 30 30
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthGuidanceDao.java
  59. 20 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java
  60. 20 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanLibraryDao.java
  61. 17 17
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPreCardDao.java
  62. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  63. 497 208
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  64. 62 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  65. 88 84
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  66. 14 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  67. 8 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  68. 180 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  69. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/DoctorService.java
  70. 24 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/httplog/LogService.java
  71. 305 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwMaternalChildService.java
  72. 204 201
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  73. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  74. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  75. 71 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prenatalInspector/PrenatalController.java
  76. 30 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java
  77. 122 78
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/PrenatalInspectorContoller.java
  78. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java
  79. 312 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/vo/SaveModel.java
  80. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  81. 215 213
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java
  82. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java
  83. 291 328
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java
  84. 1 1
      patient-co/patient-co-wlyy/src/main/resources/application.yml

+ 53 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/httpLog/HttpLogDetail.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.entity.httpLog;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2017/9/26.
 */
@Entity
@Table(name = "wlyy_http_log_detail")
public class HttpLogDetail extends IdEntity {
    private Long code;//关联code和ZyPushLog表的id
    private String response;//'返回结果',
    private String error;//'报错信息',
    private Date createTime;// '创建时间',
    public Long getCode() {
        return code;
    }
    public void setCode(Long code) {
        this.code = code;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 145 - 135
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlan.java

@ -1,135 +1,145 @@
//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;
//    }
//}
package com.yihu.wlyy.entity.patient.prenatal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.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;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "inspection_time")
    public Date getInspectionTime() {
        return inspectionTime;
    }
    public void setInspectionTime(Date inspectionTime) {
        this.inspectionTime = inspectionTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "inspection_start_time")
    public Date getInspectionStartTime() {
        return inspectionStartTime;
    }
    public void setInspectionStartTime(Date inspectionStartTime) {
        this.inspectionStartTime = inspectionStartTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "inspection_end_time")
    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;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "czrq")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

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

@ -1,107 +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;
//    }
//}
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;
    }
}

+ 549 - 442
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPreCard.java

@ -1,442 +1,549 @@
//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;
//    }
//}
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 String idcard;//身份证号
    private Date birthday;//出生日期
    private String mobile;//手机号码
    private String doctor;//团队长
    private String doctorName;//医生名称
    private String jwDoctor;//基位医生code
    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 hypertensionHistory;//'高血压',
    private String diabetesHistory;//'糖尿病',
    private String mentalDiseaseHistory;//'精神病',
    private String hyperthroidismHistory;//'甲亢',
    private String bloodDiseaseHistory;//'血液病',
    private String epilepsiaHistory;//'癫痫',
    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;//创建日期
    private String uploadStatus;// '上传状态(0未上传,1上传成功,2上传失败)',
    private String uploadMsg; //上传记录\'',
    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;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getUploadStatus() {
        return uploadStatus;
    }
    public void setUploadStatus(String uploadStatus) {
        this.uploadStatus = uploadStatus;
    }
    public String getUploadMsg() {
        return uploadMsg;
    }
    public void setUploadMsg(String uploadMsg) {
        this.uploadMsg = uploadMsg;
    }
    public String getHypertensionHistory() {
        return hypertensionHistory;
    }
    public void setHypertensionHistory(String hypertensionHistory) {
        this.hypertensionHistory = hypertensionHistory;
    }
    public String getDiabetesHistory() {
        return diabetesHistory;
    }
    public void setDiabetesHistory(String diabetesHistory) {
        this.diabetesHistory = diabetesHistory;
    }
    public String getMentalDiseaseHistory() {
        return mentalDiseaseHistory;
    }
    public void setMentalDiseaseHistory(String mentalDiseaseHistory) {
        this.mentalDiseaseHistory = mentalDiseaseHistory;
    }
    public String getHyperthroidismHistory() {
        return hyperthroidismHistory;
    }
    public void setHyperthroidismHistory(String hyperthroidismHistory) {
        this.hyperthroidismHistory = hyperthroidismHistory;
    }
    public String getBloodDiseaseHistory() {
        return bloodDiseaseHistory;
    }
    public void setBloodDiseaseHistory(String bloodDiseaseHistory) {
        this.bloodDiseaseHistory = bloodDiseaseHistory;
    }
    public String getEpilepsiaHistory() {
        return epilepsiaHistory;
    }
    public void setEpilepsiaHistory(String epilepsiaHistory) {
        this.epilepsiaHistory = epilepsiaHistory;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getJwDoctor() {
        return jwDoctor;
    }
    public void setJwDoctor(String jwDoctor) {
        this.jwDoctor = jwDoctor;
    }
}

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

@ -37,7 +37,7 @@ public class Prescription extends IdEntity {
    private String patientName;             //患者名称
    private String ssc;//社保卡号
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //(-3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
    private Integer status;                  //(-4线下退费 -3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
    // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
    // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
    // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,

+ 2 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -55,6 +55,7 @@ public class PrescriptionLog extends IdEntity {
    //状态枚举
    public enum PrescriptionLogStatus {
        pay_refund("线下退费",-4),
        //续方取消
        pay_outtime("支付超时", -3),
        patient_canel("患者自己取消", -2),
@ -124,7 +125,7 @@ public class PrescriptionLog extends IdEntity {
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
    private Integer status;                 //状态 (-4线下退费 -3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
                                               // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
                                            // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
                                            // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,

+ 291 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrenatalInspectorController.java

@ -0,0 +1,291 @@
package com.yihu.wlyy.service.controller;
import com.yihu.wlyy.service.common.model.Result;
import com.yihu.wlyy.service.service.ZysoftMaternalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2017/9/22.
 */
@RestController
@RequestMapping(value = "/third/prenatalInspector/")
@Api(description = "产检接口")
public class PrenatalInspectorController extends BaseController{
    @Autowired
    private ZysoftMaternalService maternalService;
    @RequestMapping(value = "getEhrMaternalFirstExamRecord",method = RequestMethod.POST)
    @ApiOperation("获取孕妇建卡信息")
    public Result getEhrMaternalFirstExamRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122,350204197512284026,222406198209202228,35062719831211252X")
                                                @RequestParam(value = "idcard",required = true) String idcard,
                                                @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                @RequestParam(value = "hospital",required = false) String hospital,
                                                @ApiParam(name="pregnancyNo",value="产检号")
                                                @RequestParam(value = "pregnancyNo",required = false) String pregnancyNo) throws Exception
    {
        try {
            String re = maternalService.getEhrMaternalFirstExamRecord(idcard,hospital,pregnancyNo);
            return Result.success("获取孕妇建卡信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalReExamRecord",method = RequestMethod.POST)
    @ApiOperation("获取非第一次产检记录")
    public Result getEhrMaternalReExamRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                             @RequestParam(value = "idcard",required = true) String idcard,
                                             @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                             @RequestParam(value = "hospital",required = false) String hospital,
                                             @ApiParam(name="pregnancyNo",value="产检号")
                                             @RequestParam(value = "pregnancyNo",required = true) String pregnancyNo) throws Exception{
        try {
            String re = maternalService.getEhrMaternalReExamRecord(idcard,hospital,pregnancyNo);
            return Result.success("获取非第一次产检记录成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalBedPrecontractRecord",method = RequestMethod.POST)
    @ApiOperation("获取产床预约信息")
    public Result getEhrMaternalBedPrecontractRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "35062719831211252X")
                                                     @RequestParam(value = "idcard",required = true) String idcard,
                                                     @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                     @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalBedPrecontractRecord(idcard,hospital);
            return Result.success("获取产床预约信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalPregnancyHighRecord",method = RequestMethod.POST)
    @ApiOperation("获取高危产妇信息")
    public Result getEhrMaternalPregnancyHighRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                        @RequestParam(value = "idcard",required = true) String idcard,
                                                    @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                        @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalPregnancyHighRecord(idcard,hospital);
            return Result.success("获取高危产妇信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalDeliveryRecord",method = RequestMethod.POST)
    @ApiOperation("获取孕妇分娩信息")
    public Result getEhrMaternalDeliveryRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                   @RequestParam(value = "idcard",required = true) String idcard,
                                               @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                   @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalDeliveryRecord(idcard,hospital);
            return Result.success("获取孕妇分娩信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalDeliveryChildRecord",method = RequestMethod.POST)
    @ApiOperation("获取新生儿基本信息")
    public Result getEhrMaternalDeliveryChildRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                        @RequestParam(value = "idcard",required = true) String idcard,
                                                    @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                        @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalDeliveryChildRecord(idcard,hospital);
            return Result.success("获取新生儿基本信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalChildMedicalRecord",method = RequestMethod.POST)
    @ApiOperation("获取儿童健康体检0-6岁记录")
    public Result getEhrMaternalChildMedicalRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                       @RequestParam(value = "idcard",required = true) String idcard,
                                                   @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                       @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalChildMedicalRecord(idcard,hospital);
            return Result.success("获取儿童健康体检0-6岁记录成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalHomeVisitRecord",method = RequestMethod.POST)
    @ApiOperation("获取新生儿访视信息")
    public Result getEhrMaternalHomeVisitRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                    @RequestParam(value = "idcard",required = true) String idcard,
                                                @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                    @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalHomeVisitRecord(idcard,hospital);
            return Result.success("获取新生儿访视信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalChildImmuneRecord",method = RequestMethod.POST)
    @ApiOperation("获取新生儿免疫记录")
    public Result getEhrMaternalChildImmuneRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                      @RequestParam(value = "idcard",required = true) String idcard,
                                                  @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                      @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalChildImmuneRecord(idcard,hospital);
            return Result.success("获取新生儿免疫记录成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalPreFirstExamRecord",method = RequestMethod.POST)
    @ApiOperation("获取孕妇预建卡信息")
    public Result getEhrMaternalPreFirstExamRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                       @RequestParam(value = "idcard",required = true) String idcard,
                                                   @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                       @RequestParam(value = "hospital",required = false) String hospital) throws Exception{
        try {
            String re = maternalService.getEhrMaternalPreFirstExamRecord(idcard,hospital);
            return Result.success("获取孕妇预建卡信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "SaveEhrMaternalPreFirstExamRecord",method = RequestMethod.POST)
    @ApiOperation("上传孕妇预建卡信息")
    public Result SaveEhrMaternalPreFirstExamRecord(@ApiParam(name="code",value="预建卡code",defaultValue = "352124761015122")
                                                        @RequestParam(value = "code",required = true) String code) throws Exception{
        try {
            String re = maternalService.SaveEhrMaternalPreFirstExamRecord(code);
            return Result.success("上传孕妇预建卡信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "SaveEhrMaternalHomeVisitRecord",method = RequestMethod.POST)
    @ApiOperation("上传新生儿访视信息")
    public Result SaveEhrMaternalHomeVisitRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                     @RequestParam(value = "idcard",required = true) String idcard,
                                                 @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                     @RequestParam(value = "hospital",required = true) String hospital) throws Exception{
        try {
            String re = maternalService.SaveEhrMaternalHomeVisitRecord(idcard,hospital);
            return Result.success("上传新生儿访视信息成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalZSPreDeliveryRecord",method = RequestMethod.POST)
    @ApiOperation("获取待产记录")
    public Result getEhrMaternalZSPreDeliveryRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                        @RequestParam(value = "idcard",required = true) String idcard,
                                                    @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                        @RequestParam(value = "hospital",required = true) String hospital,
                                                    @ApiParam(name="searchTime",value="查询时间")
                                                        @RequestParam(value = "searchTime",required = false) String searchTime) throws Exception{
        try {
            String re = maternalService.getEhrMaternalZSPreDeliveryRecord(idcard,hospital,searchTime);
            return Result.success("获取待产记录成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalZSDeliveryRecord",method = RequestMethod.POST)
    @ApiOperation("获取阴道分娩记录")
    public Result getEhrMaternalZSDeliveryRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                     @RequestParam(value = "idcard",required = true) String idcard,
                                                 @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                     @RequestParam(value = "hospital",required = true) String hospital,
                                                 @ApiParam(name="searchTime",value="查询时间")
                                                     @RequestParam(value = "searchTime",required = false) String searchTime) throws Exception{
        try {
            String re = maternalService.getEhrMaternalZSDeliveryRecord(idcard,hospital,searchTime);
            return Result.success("获取阴道分娩记录成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    @RequestMapping(value = "getEhrMaternalZSCaesareanBirthRecord",method = RequestMethod.POST)
    @ApiOperation("获取剖宫产记录")
    public Result getEhrMaternalZSCaesareanBirthRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122")
                                                           @RequestParam(value = "idcard",required = true) String idcard,
                                                       @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                           @RequestParam(value = "hospital",required = true) String hospital,
                                                       @ApiParam(name="searchTime",value="查询时间")
                                                           @RequestParam(value = "searchTime",required = false) String searchTime) throws Exception{
        try {
            String re = maternalService.getEhrMaternalZSCaesareanBirthRecord(idcard,hospital,searchTime);
            return Result.success("获取剖宫产记录成功!",re);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
}

+ 14 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java

@ -99,6 +99,20 @@ public class PrescriptionController extends BaseController{
		}
	}
	
	
	@RequestMapping(value = "cancelPrescription",method = RequestMethod.POST)
	@ApiOperation("接收订单退费消息")
	public Result cancelPrescription(@ApiParam(name="data",value="json串",defaultValue = "{}")
	                                 @RequestParam(value = "data",required = true) String data){
		try {
			
			return prescriptionService.cancelPrescription(data);
		}catch (Exception e){
			e.printStackTrace();
			return Result.error(e.getMessage());
		}
	}
	/***************************************获取im消息*****************************************************/
	@RequestMapping(value = "getLoglist",method = RequestMethod.GET)

+ 2 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/HttpLogDao.java

@ -3,9 +3,9 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.service.dao;
package com.yihu.wlyy.service.dao.log;
import com.yihu.wlyy.service.entity.HttpLog;
import com.yihu.wlyy.service.entity.log.HttpLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 11 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/log/HttpLogDetailDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.service.dao.log;
import com.yihu.wlyy.service.entity.log.HttpLogDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/9/26.
 */
public interface HttpLogDetailDao extends PagingAndSortingRepository<HttpLogDetail, Long>, JpaSpecificationExecutor<HttpLogDetail> {
}

+ 2 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/ZyPushLogDao.java

@ -1,6 +1,6 @@
package com.yihu.wlyy.service.dao;
package com.yihu.wlyy.service.dao.log;
import com.yihu.wlyy.service.entity.ZyPushLog;
import com.yihu.wlyy.service.entity.log.ZyPushLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 11 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/log/ZyPushLogDetailDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.service.dao.log;
import com.yihu.wlyy.service.entity.log.ZyPushLogDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/9/26.
 */
public interface ZyPushLogDetailDao extends PagingAndSortingRepository<ZyPushLogDetail, Long>, JpaSpecificationExecutor<ZyPushLogDetail> {
}

+ 19 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prenatal/PrenatalInspectorPreCardDao.java

@ -0,0 +1,19 @@
package com.yihu.wlyy.service.dao.prenatal;
import com.yihu.wlyy.service.entity.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);
    @Query("select a from PrenatalInspectorPreCard a where a.code = ?1 ")
    PrenatalInspectorPreCard findByCode(String code);
}

+ 3 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java

@ -34,4 +34,7 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Modifying
    @Query("update Prescription p set p.jwPayStatus=1 where p.code=?1")
    void updatejwPayStatus(String prescriptionCode);
    
    @Query("from Prescription p where p.visitNo=?1")
    Prescription findByVisitNo(String visitNo);
}

+ 1 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/HttpLog.java

@ -1,4 +1,4 @@
package com.yihu.wlyy.service.entity;
package com.yihu.wlyy.service.entity.log;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.service.common.model.IdEntity;

+ 52 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/log/HttpLogDetail.java

@ -0,0 +1,52 @@
package com.yihu.wlyy.service.entity.log;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2017/9/26.
 */
@Entity
@Table(name = "wlyy_http_log_detail")
public class HttpLogDetail extends IdEntity {
    private Long code;//关联code和ZyPushLog表的id
    private String response;//'返回结果',
    private String error;//'报错信息',
    private Date createTime;// '创建时间',
    public Long getCode() {
        return code;
    }
    public void setCode(Long code) {
        this.code = code;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 2 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/ZyPushLog.java

@ -1,4 +1,4 @@
package com.yihu.wlyy.service.entity;
package com.yihu.wlyy.service.entity.log;
import com.yihu.wlyy.service.common.model.IdEntity;
@ -14,7 +14,7 @@ import java.util.Date;
@Table(name = "wlyy_zy_push_log")
public class ZyPushLog extends IdEntity {
    private String type;//'接口类型 1(推送续方),2续方请求',
    private String type;//'接口类型 1(推送续方),2续方请求 3妇幼保健',
    private String content;//'业务内容',
    private String api;//'调用接口',
    private String method;//'调用方式',

+ 61 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/log/ZyPushLogDetail.java

@ -0,0 +1,61 @@
package com.yihu.wlyy.service.entity.log;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2017/9/26.
 */
@Entity
@Table(name = "wlyy_zy_push_log_detail")
public class ZyPushLogDetail extends IdEntity {
    private Long code;//关联code和ZyPushLog表的code一致
    private String response;//'返回结果',
    private String request;//'请求数据',
    private String error;//'报错信息',
    private Date createTime;// '创建时间',
    public Long getCode() {
        return code;
    }
    public void setCode(Long code) {
        this.code = code;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getRequest() {
        return request;
    }
    public void setRequest(String request) {
        this.request = request;
    }
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

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

@ -0,0 +1,550 @@
package com.yihu.wlyy.service.entity.prenatal;
import com.yihu.wlyy.service.common.model.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 String idcard;//身份证号
    private Date birthday;//出生日期
    private String mobile;//手机号码
    private String doctor;//团队长
    private String doctorName;//医生名称
    private String jwDoctor;//基位医生code
    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 hypertensionHistory;//'高血压',
    private String diabetesHistory;//'糖尿病',
    private String mentalDiseaseHistory;//'精神病',
    private String hyperthroidismHistory;//'甲亢',
    private String bloodDiseaseHistory;//'血液病',
    private String epilepsiaHistory;//'癫痫',
    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;//创建日期
    private String uploadStatus;// '上传状态(0未上传,1上传成功,2上传失败)',
    private String uploadMsg; //上传记录\'',
    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;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getUploadStatus() {
        return uploadStatus;
    }
    public void setUploadStatus(String uploadStatus) {
        this.uploadStatus = uploadStatus;
    }
    public String getUploadMsg() {
        return uploadMsg;
    }
    public void setUploadMsg(String uploadMsg) {
        this.uploadMsg = uploadMsg;
    }
    public String getHypertensionHistory() {
        return hypertensionHistory;
    }
    public void setHypertensionHistory(String hypertensionHistory) {
        this.hypertensionHistory = hypertensionHistory;
    }
    public String getDiabetesHistory() {
        return diabetesHistory;
    }
    public void setDiabetesHistory(String diabetesHistory) {
        this.diabetesHistory = diabetesHistory;
    }
    public String getMentalDiseaseHistory() {
        return mentalDiseaseHistory;
    }
    public void setMentalDiseaseHistory(String mentalDiseaseHistory) {
        this.mentalDiseaseHistory = mentalDiseaseHistory;
    }
    public String getHyperthroidismHistory() {
        return hyperthroidismHistory;
    }
    public void setHyperthroidismHistory(String hyperthroidismHistory) {
        this.hyperthroidismHistory = hyperthroidismHistory;
    }
    public String getBloodDiseaseHistory() {
        return bloodDiseaseHistory;
    }
    public void setBloodDiseaseHistory(String bloodDiseaseHistory) {
        this.bloodDiseaseHistory = bloodDiseaseHistory;
    }
    public String getEpilepsiaHistory() {
        return epilepsiaHistory;
    }
    public void setEpilepsiaHistory(String epilepsiaHistory) {
        this.epilepsiaHistory = epilepsiaHistory;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getJwDoctor() {
        return jwDoctor;
    }
    public void setJwDoctor(String jwDoctor) {
        this.jwDoctor = jwDoctor;
    }
}

+ 2 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionLog.java

@ -53,6 +53,7 @@ public class PrescriptionLog extends IdEntity {
    //状态枚举
    public enum PrescriptionLogStatus {
        //续方取消
        pay_refund("线下退费",-4),
        pay_outtime("支付超时", -3),
        patient_canel("患者自己取消", -2),
@ -121,7 +122,7 @@ public class PrescriptionLog extends IdEntity {
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
    private Integer status;                 //状态 (-4线下退费,-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
    private Integer type;                   //类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
    private String userCode;                  //医生或者患者code

+ 14 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/VO/PrescriptionExpressageVO.java

@ -48,8 +48,12 @@ public class PrescriptionExpressageVO extends Result {
    //付款方式:1:寄方付,2:收方付 3:第三方付
    private Integer pay_method;
    private String receive_time;//收件时间
    
    //收件时间
    private String receive_time;
    
    //取药类型:1 自取 2快递配送 3健管师配送
    private Integer dispensaryType;
    //订单的药品详情
    private List<PrescriptionInfo> infos = new ArrayList<>();
@ -205,4 +209,12 @@ public class PrescriptionExpressageVO extends Result {
    public void setReceive_time(String receive_time) {
        this.receive_time = receive_time;
    }
    
    public Integer getDispensaryType() {
        return dispensaryType;
    }
    
    public void setDispensaryType(Integer dispensaryType) {
        this.dispensaryType = dispensaryType;
    }
}

+ 64 - 18
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/LogService.java

@ -2,15 +2,20 @@ package com.yihu.wlyy.service.service;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.wlyy.service.dao.HttpLogDao;
import com.yihu.wlyy.service.dao.ZyPushLogDao;
import com.yihu.wlyy.service.entity.HttpLog;
import com.yihu.wlyy.service.entity.ZyPushLog;
import com.yihu.wlyy.service.dao.log.HttpLogDao;
import com.yihu.wlyy.service.dao.log.HttpLogDetailDao;
import com.yihu.wlyy.service.dao.log.ZyPushLogDao;
import com.yihu.wlyy.service.dao.log.ZyPushLogDetailDao;
import com.yihu.wlyy.service.entity.log.HttpLog;
import com.yihu.wlyy.service.entity.log.HttpLogDetail;
import com.yihu.wlyy.service.entity.log.ZyPushLog;
import com.yihu.wlyy.service.entity.log.ZyPushLogDetail;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.UUID;
/**
 * Created by hzp on 2016/9/24.
@ -25,6 +30,10 @@ public class LogService {
    private HttpLogDao httpLogDao;
    @Autowired
    private ZyPushLogDao zyPushLogDao;
    @Autowired
    private HttpLogDetailDao httpLogDetailDao;
    @Autowired
    private ZyPushLogDetailDao zyPushLogDetailDao;
    @Autowired
    private SystemDictService systemDictService;
@ -33,6 +42,10 @@ public class LogService {
    public String onePayType = "3";
    public String caType = "4";
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    /**
     * 新增开放api调用日志
     **/
@ -47,10 +60,18 @@ public class LogService {
            log.setParams(params);
            log.setCreateTime(new Date());
            log.setCreateTime(new Date());
            log.setResponse(response);
            log.setError(error);
//            log.setResponse(response);
//            log.setError(error);
            log.setStatus(isSuccess?"1":"0");
            httpLogDao.save(log);
            //明细表
            HttpLogDetail detail = new HttpLogDetail();
            detail.setCode(log.getId());
            detail.setCreateTime(new Date());
            detail.setResponse(response);
            detail.setError(error);
            httpLogDetailDao.save(detail);
        }
        catch (Exception ex)
        {
@ -67,18 +88,31 @@ public class LogService {
            log.setCreateTime(new Date());
            log.setApi(api);
            log.setContent(content);
            log.setError(error);
//            log.setError(error);
            log.setMethod(method);
            log.setRequest(request);
            if(re.length()>10652261){
                log.setResponse("超过longtext限制");
            }else {
                log.setResponse(JSONObject.toJSONString(re, SerializerFeature.WriteMapNullValue));
            }
//            log.setRequest(request);
//            if(re.length()>10652261){
//                log.setResponse("超过longtext限制");
//            }else {
//                log.setResponse(JSONObject.toJSONString(re, SerializerFeature.WriteMapNullValue));
//            }
            log.setRetryTimes(0);
            log.setStatus(status);
            log.setType(type);
            zyPushLogDao.save(log);
            //明细表
            ZyPushLogDetail detail = new ZyPushLogDetail();
            detail.setCode(log.getId());
            detail.setError(error);
            detail.setCreateTime(new Date());
            if(re.length()>10652261){
                detail.setResponse("超过longtext限制");
            }else {
                detail.setResponse(JSONObject.toJSONString(re, SerializerFeature.WriteMapNullValue));
            }
            detail.setRequest(request);
            zyPushLogDetailDao.save(detail);
        }catch (Exception e){
            e.printStackTrace();
            logger.info("保存数据日志出错");
@ -112,14 +146,26 @@ public class LogService {
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
//                if(response.length()>10652261){
//                    log.setResponse("超过longtext限制");
//                }else {
//                    log.setResponse(response);
//                }
//                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                //明细表
                HttpLogDetail detail = new HttpLogDetail();
                detail.setCode(log.getId());
                detail.setCreateTime(new Date());
                if(response.length()>10652261){
                    log.setResponse("超过longtext限制");
                    detail.setResponse("超过longtext限制");
                }else {
                    log.setResponse(response);
                    detail.setResponse(response);
                }
                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                detail.setError(error);
                httpLogDetailDao.save(detail);
            }
        }
        catch (Exception ex)

+ 0 - 8
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/OpenCountService.java

@ -2,22 +2,14 @@ package com.yihu.wlyy.service.service;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.prism.impl.paint.PaintUtil;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.dao.HospitalMappingDao;
import com.yihu.wlyy.service.dao.HttpLogDao;
import com.yihu.wlyy.service.dao.QuotaResultDao;
import com.yihu.wlyy.service.dao.SignFamilyLogDao;
import com.yihu.wlyy.service.entity.HospitalMapping;
import com.yihu.wlyy.service.entity.HttpLog;
import com.yihu.wlyy.service.entity.QuotaResult;
import com.yihu.wlyy.service.entity.SignFamilyLog;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**

+ 21 - 9
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftBaseService.java

@ -8,9 +8,11 @@ import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.model.Result;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.dao.HospitalMappingDao;
import com.yihu.wlyy.service.dao.ZyPushLogDao;
import com.yihu.wlyy.service.dao.log.ZyPushLogDao;
import com.yihu.wlyy.service.dao.log.ZyPushLogDetailDao;
import com.yihu.wlyy.service.entity.HospitalMapping;
import com.yihu.wlyy.service.entity.ZyPushLog;
import com.yihu.wlyy.service.entity.log.ZyPushLog;
import com.yihu.wlyy.service.entity.log.ZyPushLogDetail;
import com.zoe.phip.ssp.sdk.ApiException;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -39,7 +41,8 @@ public class ZysoftBaseService {
    private HospitalMappingDao hospitalMappingDao;
    @Autowired
    private ZyPushLogDao zyPushLogDao;
    @Autowired
    private ZyPushLogDetailDao zyPushLogDetailDao;
    //默认重复次数
    private int retryTimes = 3;
@ -73,15 +76,24 @@ public class ZysoftBaseService {
        log.setCreateTime(new Date());
        log.setApi(api);
        log.setContent(content);
        log.setError(error);
//        log.setError(error);
        log.setMethod(method);
        log.setRequest(request);
        log.setResponse(JSONObject.toJSONString(re,SerializerFeature.WriteMapNullValue));
//        log.setRequest(request);
//        log.setResponse(JSONObject.toJSONString(re,SerializerFeature.WriteMapNullValue));
        log.setRetryTimes(0);
        log.setStatus(status);
        log.setType(type);
        zyPushLogDao.save(log);
        //明细表
        ZyPushLogDetail detail = new ZyPushLogDetail();
        detail.setCode(log.getId());
        detail.setError(error);
        detail.setCreateTime(new Date());
        detail.setResponse(JSONObject.toJSONString(re,SerializerFeature.WriteMapNullValue));
        detail.setRequest(request);
        zyPushLogDetailDao.save(detail);
        return re;
    }
@ -186,7 +198,7 @@ public class ZysoftBaseService {
    /**
     * 基卫二次封装Post接口
     */
    public String postSecond(String api,String content, Map<String,String> params,JSONObject jsonParams, Map<String,String> headers,boolean needRetry,Integer apiType) throws Exception
    public String postSecond(String api,String content, Map<String,String> params,JSONObject jsonParams, Map<String,String> headers,boolean needRetry,Integer apiType,String type) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
@ -232,7 +244,7 @@ public class ZysoftBaseService {
//            com.alibaba.fastjson.JSONObject j = com.alibaba.fastjson.JSONObject.parseObject(re);
            //保存http日志
//            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            logService.saveZyPushLog(api,content,null,"POST",msgHeader+","+msgBody,re,"1","2");
            logService.saveZyPushLog(api,content,null,"POST",msgHeader+","+msgBody,re,"1",type);
        }
        catch (Exception ex)
        {
@ -243,7 +255,7 @@ public class ZysoftBaseService {
            //保存http日志
//            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            logService.saveZyPushLog(api,content,error,"POST",msgHeader+","+msgBody,re,"0","2");
            logService.saveZyPushLog(api,content,error,"POST",msgHeader+","+msgBody,re,"0",type);
            if(ex instanceof ApiException)
            {

+ 177 - 90
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftMaternalService.java

@ -1,5 +1,13 @@
package com.yihu.wlyy.service.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.common.util.DateUtil;
import com.yihu.wlyy.service.dao.SignFamilyDao;
import com.yihu.wlyy.service.dao.prenatal.PrenatalInspectorPreCardDao;
import com.yihu.wlyy.service.entity.SignFamily;
import com.yihu.wlyy.service.entity.prenatal.PrenatalInspectorPreCard;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@ -13,12 +21,21 @@ import java.util.Map;
@Service
public class ZysoftMaternalService extends ZysoftBaseService{
    @Autowired
    private PrenatalInspectorPreCardDao preCardDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    /**
     * 7.32获取孕妇建卡信息(妇幼保健)
     */
    public String getEhrMaternalFirstExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception
    public String getEhrMaternalFirstExamRecord(String idcard,String hospitalCode,String pregnancyNo) throws Exception
    {
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -26,9 +43,9 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        params.put("PREGNANCY_NO",pregnancyNo);
        String response = postSecond("getEhrMaternalFirstExamRecord","获取孕妇建卡信息",params,null,header,false,1);
        String response = postSecond("getEhrMaternalFirstExamRecord","获取孕妇建卡信息",params,null,header,false,1,"3");
        return response;
    }
@ -36,13 +53,17 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.33 获取非第一次产检记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @param pregnancyNo 产检号
     * @return
     * @throws Exception
     */
    public String getEhrMaternalReExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalReExamRecord(String idcard,String hospitalCode,String pregnancyNo) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -50,9 +71,9 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        params.put("PREGNANCY_NO",pregnancyNo);
        String response = postSecond("getEhrMaternalReExamRecord","获取非第一次产检记录",params,null,header,false,1);
        String response = postSecond("getEhrMaternalReExamRecord","获取非第一次产检记录",params,null,header,false,1,"3");
        return response;
    }
@ -60,13 +81,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.34 获取产床预约信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalBedPrecontractRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalBedPrecontractRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -74,9 +97,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalBedPrecontractRecord","获取产床预约信息",params,null,header,false,1);
        String response = postSecond("getEhrMaternalBedPrecontractRecord","获取产床预约信息",params,null,header,false,1,"3");
        return response;
    }
@ -84,13 +106,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.35 获取高危产妇信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPregnancyHighRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalPregnancyHighRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -98,9 +122,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalPregnancyHighRecord","获取高危产妇信息",params,null,header,false,1);
        String response = postSecond("getEhrMaternalPregnancyHighRecord","获取高危产妇信息",params,null,header,false,1,"3");
        return response;
    }
@ -108,13 +131,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.36 获取孕妇分娩信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalDeliveryRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -122,9 +147,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalDeliveryRecord","获取孕妇分娩信息",params,null,header,false,1);
        String response = postSecond("getEhrMaternalDeliveryRecord","获取孕妇分娩信息",params,null,header,false,1,"3");
        return response;
    }
@ -132,13 +156,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.37 获取新生儿基本信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryChildRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalDeliveryChildRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -146,9 +172,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalDeliveryChildRecord","获取新生儿基本信息",params,null,header,false,1);
        String response = postSecond("getEhrMaternalDeliveryChildRecord","获取新生儿基本信息",params,null,header,false,1,"3");
        return response;
    }
@ -156,13 +181,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.38 获取儿童健康体检0-6岁记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildMedicalRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalChildMedicalRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -170,9 +197,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalChildMedicalRecord","获取儿童健康体检0-6岁记录",params,null,header,false,1);
        String response = postSecond("getEhrMaternalChildMedicalRecord","获取儿童健康体检0-6岁记录",params,null,header,false,1,"3");
        return response;
    }
@ -180,13 +206,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.39 获取新生儿访视信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalHomeVisitRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalHomeVisitRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -194,9 +222,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalHomeVisitRecord","获取新生儿访视信息",params,null,header,false,1);
        String response = postSecond("getEhrMaternalHomeVisitRecord","获取新生儿访视信息",params,null,header,false,1,"3");
        return response;
    }
@ -204,13 +231,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.40 获取新生儿免疫记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildImmuneRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalChildImmuneRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -218,9 +247,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalChildImmuneRecord","获取新生儿免疫记录",params,null,header,false,1);
        String response = postSecond("getEhrMaternalChildImmuneRecord","获取新生儿免疫记录",params,null,header,false,1,"3");
        return response;
    }
@ -228,13 +256,14 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.41 获取孕妇预建卡信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPreFirstExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalPreFirstExamRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -242,33 +271,83 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalPreFirstExamRecord","获取孕妇预建卡信息",params,null,header,false,1);
        String response = postSecond("getEhrMaternalPreFirstExamRecord","获取孕妇预建卡信息",params,null,header,false,1,"3");
        return response;
    }
    /**
     * 7.42 上传孕妇预建卡信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param code 预建卡code
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalPreFirstExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String SaveEhrMaternalPreFirstExamRecord(String code) throws Exception{
        PrenatalInspectorPreCard preCard = preCardDao.findByCode(code);
        JSONObject json = new JSONObject();
        json.put("SICK_NAME",preCard.getName());//姓名
        json.put("IDENTITY_CARD_NO",preCard.getIdcard());//身份证号码
        json.put("HEALTH_CARD_NO",preCard.getSsc());//孕妇医保卡
        json.put("BIRTHDAY",DateUtil.dateToStrLong(preCard.getBirthday()));//出生日期
        json.put("SICK_PHONE",preCard.getMobile());//手机号码
        json.put("MENSES_LAST",DateUtil.dateToStrLong(preCard.getLastMenstrualDate()));//末次月经
        json.put("ALLERGIC_HISTORY",preCard.getAllergyHistory());//过敏史
        json.put("MARITAL_STATE",preCard.getMaritalStatus());//婚姻情况
        json.put("SICK_ADDRESS",preCard.getResidentialAddress());//现居地址
        json.put("PERMANENT_ADDRESS_",preCard.getPermanentAddress());//户籍地址
        json.put("WEDDING_DATE_",DateUtil.dateToStrLong(preCard.getMarryDate()));//结婚日期
        json.put("LOVER_NAME",preCard.getSpouseName());//配偶姓名
        json.put("LOVER_BIRTHDAY",DateUtil.dateToStrLong(preCard.getSpouseBirthday()));//配偶生日
        json.put("LOVER_PHONE",preCard.getSpouseMobile());//配偶手机
        json.put("TAKE_FOLACIN",preCard.getEatFolate());//是否服用叶酸
        json.put("TAKE_ACYETERION",preCard.getEatAcyeterion());//是否服避孕药
        json.put("SMOKE",preCard.getSmoke());//是否吸烟
        json.put("DRUNK",preCard.getDrink());//是否饮酒
        json.put("PREGNANCY_NOW_HISTROY_OTHER",preCard.getEatOtherDrugs());//服用其他药物
        json.put("SICK_WORK_COMPANY",preCard.getWorkUnit());//工作单位
        json.put("HEIGHT",preCard.getHeight());//身高
        json.put("WEIGHT",preCard.getWeight());//体重
        json.put("VAGINAL_DELIVERY_TIMES",preCard.getVaginalDeliveryTimes());//阴道分娩次数
        json.put("CESAREAN_SECTION_TIMES",preCard.getCaesareanSectionTimes());//剖宫产次数
        json.put("MENARCHE_AGE",preCard.getMenarcheAge());//初潮
        json.put("PERIOD_DURATION",preCard.getMenstrualPeriod());//经期
        json.put("MENSTRUAL_CYCLE",preCard.getMenstrualCycle());//周期
        json.put("HYPERTENSION_HISTORY",preCard.getHypertensionHistory());//高血压
        json.put("DIABETES_HISTORY",preCard.getDiabetesHistory());//糖尿病
        json.put("MENTAL_DISEASE_HISTORY",preCard.getMentalDiseaseHistory());//精神病
        json.put("HYPERTHYROIDISM_HISTORY",preCard.getHyperthroidismHistory());//甲亢
        json.put("BLOOD_DISEASE_HISTORY",preCard.getBloodDiseaseHistory());//血液病
        json.put("EPILEPSIA_HISTORY",preCard.getEpilepsiaHistory());//癫痫
        json.put("OPERATION_HISTORY",preCard.getOperationHistory());//手术史
        json.put("OTHER_HISTORY",preCard.getOtherInformation());//其他
        json.put("QUERY_TIME",DateUtil.dateToStrLong(preCard.getCzrq()));//询问时间
        json.put("EXPECTED_TIME",DateUtil.dateToStrLong(preCard.getDueDate()));//预产期
        json.put("EXAM_TIME",DateUtil.dateToStrLong(preCard.getCzrq()));//检查时间
        SignFamily signFamily = signFamilyDao.findByPatient(preCard.getPatient());
        String[] hospitalMapping = getHospitalMapping(signFamily.getHospital()); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("SaveEhrMaternalPreFirstExamRecord","上传孕妇预建卡信息",params,null,header,false,1);
        header.put("OPERATOR",preCard.getJwDoctor());
        String response = postSecond("SaveEhrMaternalPreFirstExamRecord","上传孕妇预建卡信息",null,json,header,false,1,"3");
        JSONObject re = JSONObject.parseObject(response);
        JSONArray data = re.getJSONArray("DATA");
        if(data.size()>0&&"OK".equals(data.getJSONObject(0).getString("MESSAGE"))){
            preCard.setUploadStatus("1");
        }else {
            preCard.setUploadStatus("2");
        }
        preCard.setUploadMsg(response);
        preCardDao.save(preCard);
        return response;
    }
@ -276,13 +355,14 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.43 上传新生儿访视信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalHomeVisitRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String SaveEhrMaternalHomeVisitRecord(String idcard,String hospitalCode) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -290,9 +370,8 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("SaveEhrMaternalHomeVisitRecord","上传新生儿访视信息",params,null,header,false,1);
        String response = postSecond("SaveEhrMaternalHomeVisitRecord","上传新生儿访视信息",params,null,header,false,1,"3");
        return response;
    }
@ -301,12 +380,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
     * 7.44 获取待产记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSPreDeliveryRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalZSPreDeliveryRecord(String idcard,String hospitalCode,String searchTime) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -314,9 +396,9 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("PUERPERA_ID_NUMBER",idcard);
        params.put("TPP_RECORD_DATE_TIME",searchTime);
        params.put("TPP_RECORD_DATE_TIME",searchTime);//身份证和查询时间必填一个,区间为一天
        String response = postSecond("getEhrMaternalZSPreDeliveryRecord","获取待产记录",params,null,header,false,1);
        String response = postSecond("getEhrMaternalZSPreDeliveryRecord","获取待产记录",params,null,header,false,1,"3");
        return response;
    }
@ -325,12 +407,15 @@ public class ZysoftMaternalService extends ZysoftBaseService{
     * 7.45 获取阴道分娩记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSDeliveryRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalZSDeliveryRecord(String idcard,String hospitalCode,String searchTime) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
@ -340,7 +425,7 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        params.put("PUERPERA_ID_NUMBER",idcard);
        params.put("CREATE_TIME",searchTime);
        String response = postSecond("getEhrMaternalZSDeliveryRecord","获取阴道分娩记录",params,null,header,false,1);
        String response = postSecond("getEhrMaternalZSDeliveryRecord","获取阴道分娩记录",params,null,header,false,1,"3");
        return response;
    }
@ -348,23 +433,25 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.46 获取剖宫产记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @param hospitalCode
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSCaesareanBirthRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
    public String getEhrMaternalZSCaesareanBirthRecord(String idcard,String hospitalCode,String searchTime) throws Exception{
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("PUERPERA_ID_NUMBER",idcard);
        params.put("PUERPERA_ID_NUMBER",idcard);//身份证和查询时间必填一个
        params.put("CREATE_TIME",searchTime);
        String response = postSecond("getEhrMaternalZSCaesareanBirthRecord","获取剖宫产记录",params,null,header,false,1);
        String response = postSecond("getEhrMaternalZSCaesareanBirthRecord","获取剖宫产记录",params,null,header,false,1,"3");
        return response;
    }

Разлика између датотеке није приказан због своје велике величине
+ 71 - 36
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java


+ 115 - 7
patient-co-service/wlyy_service/src/main/webapp/prescription_consulting/js/prescription_consulting_info.js

@ -4,9 +4,12 @@ var request = GetRequest(),
    dialroll,
    page = 1,
    prepend =  false; 
//var server = "http://192.168.131.24:8081/";
var imgUrlDomain = "http://10.95.22.10:8011/";//正式
//var server = "http://192.168.131.24:8081/";//本地
//var server = "http://172.19.103.88:8011/wlyy_service/";//测试
var server = "http://10.95.22.10:8011/wlyy_service/";//正式
// var imgUrlDomain = "http://172.19.103.54/";//测试
$(function(){
    dialroll = iscrollAssist.newVerScrollForPull($('.pull-iscroll-wrap'), pulldownAction, null);
@ -17,6 +20,7 @@ $(function(){
    $("#talkwrap").height(totH);
    
    getLogList();
    bindEvents();
})
function getLogList(){
@ -115,7 +119,7 @@ function addReply(msgObj, member, prepend){
    }
    
    var temp = '<dt style="height: auto; text-align: center;">'+
        '<a><img src="' + p + '" class="c-images-cycle" /></a></dt>' +
        '<a><img src="' + getImgUrl(p) + '" class="c-images-cycle" /></a></dt>' +
        '<div class="c-content"><span class="c-f12 name">' + member.name + '</span>'
    
    switch(parseInt(msgType)) {
@ -133,7 +137,7 @@ function addReply(msgObj, member, prepend){
                '</dd></dl>';
            break;
        case 2://图片
            temp += '<dd class="word-bread wb-img"><img width="100" height="100" src="'+ content +'" /></dd></dl>';
            temp += '<dd class="word-bread wb-img"><img width="100" height="100" src="'+ getImgUrl(content) +'" /></dd></dl>';
            break;
        case 3://语音
            var rec = JSON.parse(content);
@ -146,16 +150,16 @@ function addReply(msgObj, member, prepend){
        case 12://视频
            var videoInfo = content.split(",");
            var shichang = formatSeconds(videoInfo[2]);//时长
            if(type == 1){
                temp += '<dd class="preview-video" data-video="'+videoInfo[1]+'">'+
                        '<img class="video-img-left" src="'+videoInfo[0]+'">'+
            if(member.is_patient == 0){
                temp += '<dd class="preview-video" data-video="'+getImgUrl(videoInfo[1])+'">'+
                        '<img class="video-img-left" src="'+getImgUrl(videoInfo[0])+'">'+
                        '<img class="bofang-icon-left" src="images/bofang_icon.png">'+
                        '<img class="jianjiao-icon-left" src="images/zuoshanjiao_bg.png">'+
                        '<span class="shichang-time-left">'+shichang+'</span>'+
                    '</dd>';
            }else{
                temp += '<dd class="preview-video" data-video="'+videoInfo[1]+'">'+
                        '<img class="video-img-right" src="'+videoInfo[0]+'">'+
                temp += '<dd class="preview-video" data-video="'+getImgUrl(videoInfo[1])+'">'+
                        '<img class="video-img-right" src="'+getImgUrl(videoInfo[0])+'">'+
                        '<img class="bofang-icon-right" src="images/bofang_icon.png">'+
                        '<img class="jianjiao-icon-right" src="images/youshanjiao_bg.png">'+
                        '<span class="shichang-time-right">'+shichang+'</span>'+
@ -185,6 +189,47 @@ function addReply(msgObj, member, prepend){
    
}
function bindEvents(){
    $(".talk-box").on('click', '.audio', function(){
        dialog({
            contentType:'tipsbox', 
            skin:'bk-popup' ,
            bottom:true,
            content:'暂不支持多媒体内容播放'
        }).show();
//      if($playingDom){
//          aud.pause();
//          //aud.stop();
//          $playingDom.removeClass('active');
//          if($playingDom[0] == this){
//              $playingDom = null;
//              return;
//          }
//      }
//      $playingDom = $(this);
//      $playingDom.addClass('active');
//      var ser = JSON.parse($(this).attr('data-audio'));
//      aud.src = getImgUrl(ser.path);
//      aud.load();
//      aud.play();
    })
    //播放视频
    .on('click','.preview-video',function() {
        dialog({
            contentType:'tipsbox', 
            skin:'bk-popup' ,
            bottom:true,
            content:'暂不支持多媒体内容播放'
        }).show();
//          $(document.body).find('video').remove();
//          var url = $(this).attr('data-video');
//          var html = '<video style="display: none;"  controls preload="auto" width="1" height="1" src="'+url+'" ></video>';
//          $(document.body).append(html);
//          var video = $(document.body).find('video')[0];
//          video.play();
    });
}
function queryFailed(res){
    d.close();
   
@ -213,6 +258,48 @@ function GetRequest() {
   return theRequest;
}
//毫秒转换成时分秒
function formatSeconds(value){
    var theTime = parseInt(value/1000);// 秒
    var theTime1 = 0;// 分
    var theTime2 = 0;// 小时
    if(theTime > 60) {
        theTime1 = parseInt(theTime/60);
        theTime = parseInt(theTime%60);
            if(theTime1 > 60) {
                theTime2 = parseInt(theTime1/60);
                theTime1 = parseInt(theTime1%60);
            }
    }
    var result = ""+parseInt(theTime);//秒
    if(parseInt(theTime)<=9){
        result = "0"+parseInt(theTime);//秒
    }
    if(theTime1 > 0) {//分
        if(parseInt(theTime1)>9){
            result = ""+parseInt(theTime1)+":"+result;
        }else{
            result = "0"+parseInt(theTime1)+":"+result;
        }
    }
    if(theTime2 > 0) {//小时
        if(parseInt(theTime2)>9){
            result = ""+parseInt(theTime2)+":"+result;
        }else{
            result = "0"+parseInt(theTime2)+":"+result;
        }
    }
    var resResult = "";
    if(result.split(":").length==1){//秒
        resResult = "00:"+result;
    }else if(result.split(":").length==2){//分
        resResult = "00:"+result;
    }else{//时
        resResult = result;
    }
    return resResult;
}
Date.prototype.Format = function(formatStr)   
{   
    var str = formatStr;   
@ -238,4 +325,25 @@ Date.prototype.Format = function(formatStr)
    str=str.replace(/s|S/g,this.getSeconds());   
  
    return str;   
}
/*
 * 获取图片路径方法修改
 */
function getImgUrl(str){
    if(typeof str != 'string'){
        return "";
    }
    if(str.length == 0){
        return "";
    }else{
        if(str.indexOf("../")>-1){
            //访问本地路径
            return str;
        }else if((str.indexOf("http://")>-1) || (str.indexOf("https://")>-1)){
            return str;
        }else{
            //服务器上的图片路径
            return imgUrlDomain + str;
        }
    }
}

+ 11 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/HttpLogDetailDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.sign.dao;
import com.yihu.wlyy.sign.entity.HttpLogDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/9/26.
 */
public interface HttpLogDetailDao extends PagingAndSortingRepository<HttpLogDetail, Long>, JpaSpecificationExecutor<HttpLogDetail> {
}

+ 53 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/entity/HttpLogDetail.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.sign.entity;
import com.yihu.wlyy.sign.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2017/9/26.
 */
@Entity
@Table(name = "wlyy_http_log_detail")
public class HttpLogDetail extends IdEntity {
    private Long code;//关联code和ZyPushLog表的id
    private String response;//'返回结果',
    private String error;//'报错信息',
    private Date createTime;// '创建时间',
    public Long getCode() {
        return code;
    }
    public void setCode(Long code) {
        this.code = code;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 24 - 6
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/LogService.java

@ -2,8 +2,10 @@ package com.yihu.wlyy.sign.service;
import com.yihu.wlyy.sign.common.util.StringUtil;
import com.yihu.wlyy.sign.dao.HttpLogDao;
import com.yihu.wlyy.sign.dao.HttpLogDetailDao;
import com.yihu.wlyy.sign.dao.SignFamilyLogDao;
import com.yihu.wlyy.sign.entity.HttpLog;
import com.yihu.wlyy.sign.entity.HttpLogDetail;
import com.yihu.wlyy.sign.entity.SignFamilyLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -19,10 +21,10 @@ public class LogService {
    @Autowired
    private HttpLogDao httpLogDao;
    @Autowired
    private HttpLogDetailDao httpLogDetailDao;
    @Autowired
    private SignFamilyLogDao signFamilyLogDao;
    @Autowired
    private SystemDictService systemDictService;
@ -40,10 +42,18 @@ public class LogService {
            log.setParams(params);
            log.setCreateTime(new Date());
            log.setCreateTime(new Date());
            log.setResponse(response);
            log.setError(error);
//            log.setResponse(response);
//            log.setError(error);
            log.setStatus(isSuccess?"1":"0");
            httpLogDao.save(log);
            //明细表
            HttpLogDetail detail = new HttpLogDetail();
            detail.setCode(log.getId());
            detail.setCreateTime(new Date());
            detail.setResponse(response);
            detail.setError(error);
            httpLogDetailDao.save(detail);
        }
        catch (Exception ex)
        {
@ -76,10 +86,18 @@ public class LogService {
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
                log.setResponse(response);
                log.setError(error);
//                log.setResponse(response);
//                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                //明细表
                HttpLogDetail detail = new HttpLogDetail();
                detail.setCode(log.getId());
                detail.setCreateTime(new Date());
                detail.setResponse(response);
                detail.setError(error);
                httpLogDetailDao.save(detail);
            }
        }
        catch (Exception ex)

+ 8 - 0
patient-co/patient-co-statistics-es/pom.xml

@ -441,6 +441,14 @@
            <artifactId>elasticsearch-sql</artifactId>
            <version>2.4.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
    </dependencies>
    <build>

+ 15 - 4
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/ElasticsearchUtil.java

@ -2,10 +2,14 @@ package com.yihu.wlyy.statistics.util;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
import com.alibaba.druid.sql.parser.ParserException;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.alibaba.druid.sql.parser.Token;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.vo.SaveModel;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.nlpcn.es4sql.domain.Select;
import org.nlpcn.es4sql.jdbc.ObjectResult;
import org.nlpcn.es4sql.jdbc.ObjectResultsExtractor;
@ -254,7 +258,7 @@ public class ElasticsearchUtil {
        StringBuffer groupBy = new StringBuffer();
        //根据 childAreaLevel   group by
        if (SaveModel.teamLevel.equals(childAreaLevel)) {
            sql.append("select team,teamName,result1,result2 from wlyy_quota_test where  '");
            sql.append("select team,teamName,result1,result2 from wlyy_quota_test where  ");
        } else if (SaveModel.OrgLevel.equals(childAreaLevel)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where  ");
            groupBy.append(" group by hospital,hospitalName");
@ -305,7 +309,9 @@ public class ElasticsearchUtil {
            SQLExprParser parser = new ElasticSqlExprParser(sql);
            SQLExpr expr = parser.expr();
            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
//            if (parser.getLexer().token() != Token.EOF) {
//                throw new ParserException("illegal sql expr : " + sql);
//            }
            Select select = null;
            select = new SqlParser().parseSelect(queryExpr);
@ -319,11 +325,13 @@ public class ElasticsearchUtil {
                requestBuilder = action.explain();
            } else {
                //封装成自己的Select对象
                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
                Client client = elasticFactory.getTransportClient();
                queryAction = new DefaultQueryAction(client, select);
                requestBuilder = queryAction.explain();
            }
            SearchResponse response = (SearchResponse) requestBuilder.get();
            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getAggregations(), true);
//            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getAggregations(), true);
            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getHits(), true);
            List<String> heads = temp.getHeaders();
            temp.getLines().stream().forEach(one -> {
                try {
@ -331,6 +339,9 @@ public class ElasticsearchUtil {
                    for (int i = 0; i < one.size(); i++) {
                        String key = null;
                        Object value = one.get(i);
                        if(heads.get(i).startsWith("_")){
                            continue;
                        }
                        if (heads.get(i).contains("date_histogram")) {
                            key = "setQuotaDate";
                            value=DateUtil.strToDate(String.valueOf(value),"yyyy-MM-dd HH:mm:ss");

BIN
patient-co/patient-co-statistics/doc/业务文档/统计指标流程.docx


+ 1 - 1
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/QuartzJobLog.java

@ -81,7 +81,7 @@ public class QuartzJobLog implements java.io.Serializable {
	}
	public void setJobContent(String jobContent) {
		this.jobContent = jobContent;
		this.jobContent = "";
	}
	@Column(name = "job_type", length = 1)

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

@ -74,11 +74,11 @@ public class HealthArtListener implements MessageListener {
                }
                // 推送消息给微信端
                org.json.JSONObject json = new org.json.JSONObject();
                json.put("first", patient.getName() + ",您好! " + one.getSendName() + "医生给您发来了一篇患教文章");
                json.put("first", patient.getName() + ",您好! " + one.getSendName() + (one.getSendType()==2 ? "卫计委":"医生") +"给您发来了一篇患教文章");
                json.put("toUser", patient.getCode());
                json.put("article", one.getArticleId() + "");
                json.put("title", one.getAttachedTitle());
                json.put("doctorName", one.getSendName());
                json.put("doctorName", one.getSendName()+(one.getSendType()==2 ? "卫计委":"医生"));
                json.put("represented", patient.getCode());//被代理人
                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage());

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

@ -125,6 +125,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("patient_disease_contion_syn_job  job exist");
            }
    
            //查询家庭签约支付结果,补更新医保签约号,3分钟跑一次
            if (!quartzHelper.isExistJob("sign_family_pay_result_migisterno_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_family_pay_result_migisterno_job");
                quartzHelper.addJob(SignFamilyPayResultJob.class, trigger, "sign_family_pay_result_migisterno_job", new HashMap<String, Object>());
                logger.info("sign_family_pay_result_migisterno_job  job success");
            } else {
                logger.info("sign_family_pay_result_migisterno_job  job exist");
            }

+ 2 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionExecuteSickSettleJob.java

@ -28,7 +28,7 @@ public class PrescriptionExecuteSickSettleJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("START=====开始执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
//        logger.info("START=====开始执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
        try {
            //获取支付完成,院内结算失败的 处方CODE 集合
            List<String> prescriptionCodeList = prescriptionService.findCodesByPayStautsAndExecuteSickStatus();
@ -43,7 +43,7 @@ public class PrescriptionExecuteSickSettleJob implements Job {
                    }
                }
            }
        logger.info("END========执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
//        logger.info("END========执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("END===ERROE===执行长处方支付成功,院内结算失败,重新执行院内结算的JOB,message:"+e.getMessage());

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

@ -38,15 +38,15 @@ public class SFExpressJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            logger.info("顺丰快递JOB开始:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
//            logger.info("顺丰快递JOB开始:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
            List<PrescriptionExpressage> expresslist = prescriptionExpressageService.findByPrescriptionPaidExpressOrderFail();
            if(!expresslist.isEmpty()){
                logger.info("顺丰快递JOB:找到"+expresslist.size()+"条下单失败记录,开始重新下单"+ DateUtil.getNowDate());
//                logger.info("顺丰快递JOB:找到"+expresslist.size()+"条下单失败记录,开始重新下单"+ DateUtil.getNowDate());
                sfexpressService.reOrderExpress(expresslist);
            }else{
                logger.info("顺丰快递JOB:未找到下单失败的处方快递记录"+ DateUtil.getNowDate());
//                logger.info("顺丰快递JOB:未找到下单失败的处方快递记录"+ DateUtil.getNowDate());
            }
            logger.info("顺丰快递JOB结束:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
//            logger.info("顺丰快递JOB结束:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("顺丰快递JOB执行出错:错误信息"+ e.getMessage());

+ 36 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignFamilyPayResultJob.java

@ -0,0 +1,36 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
/**
 * 遍历没有医保签约号的家庭签约支付记录,
 * 查询家庭签约支付结果,补更新医保签约号
 * @author huangwenjie
 * @date 2017/9/29 11:04
 */
public class SignFamilyPayResultJob implements Job {
	private static final Logger logger = LoggerFactory.getLogger(SignFamilyPayResultJob.class);
	
	@Autowired
	private PatientPrescriptionPayService payService;
	
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		try {
			//根据起止时间查询家签慢病患者定标情况,并同步到本地数据库
			payService.getSignFamilyPayResultJob(new Date(),DateUtil.getNextMin(new Date(),-(60*24)));
		}catch (Exception e){
			e.printStackTrace();
			logger.info("END===ERROE==遍历没有医保签约号的家庭签约支付记录JOB,message:"+e.getMessage());
		}
	}
}

+ 4 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -95,8 +95,10 @@ public class RedisThread implements Runnable {
            }else if("wechat".equals(title)){
                String data = json.getString("value");
                pushMsgTask.getQueue().put(new org.json.JSONObject(data));
            }else{
            }else if("adjustPrescription".equals(title)){
                //线下调整处方完成
                String prescriptionCode = json.getString("prescription");
                prescriptionService.setPrescriptionInfo(prescriptionCode);
            }
        }catch (Exception e){
            logger.error("redis_error...",e);

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

@ -59,4 +59,7 @@ public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>,
    int updateByChargeCode(String chargeCode, String chargeTime, Date updateTime, Integer totalAmount, Integer insuranceAmount, Integer selfPayAmount, String billNo, String miRegisterNo,String tradeStatus);
    List<WlyyCharge> findByPatient(String patient, Pageable pageRequest);
    
    @Query(value = "select * from wlyy_charge where trade_status = ?1 AND (mi_register_no IS null OR mi_register_no = '') AND update_time BETWEEN ?2  and ?3",nativeQuery = true)
    List<WlyyCharge> findByTradeStatusAndMiRegisterNoAndUpdateTime(int tradestatus, Date enddate, Date startdate);
}

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

@ -22,7 +22,7 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Query("select p from Prescription p where p.jwCode=?1 and p.status=?2 ")
    List<Prescription> fingdByJwCodeAndStatus(String jwcode,Integer status);
    @Query(value = "select p.prescription_code from wlyy_prescription_pay p LEFT JOIN  wlyy_prescription a on a.code = p.prescription_code where p.trade_status = 1 and a.jw_pay_status = 0",nativeQuery = true)
    @Query(value = "select p.prescription_code from wlyy_prescription_pay p LEFT JOIN  wlyy_prescription a on a.code = p.prescription_code where p.trade_status = 1 and a.jw_pay_status = 0 and a.status=50",nativeQuery = true)
    List<String> findCodesByPayStautsAndExecuteSickStatus();
    @Modifying

+ 2 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -165,6 +165,7 @@ public class FamilyMemberService extends BaseService {
        //设置家人openid
        if(StringUtils.isBlank(m.getOpenid())){
            m.setOpenid(p.getOpenid());
            m.setOpenidTime(new Date());
            patientDao.save(m);
        }
@ -1130,6 +1131,7 @@ public class FamilyMemberService extends BaseService {
        //设置家人openid
        if(StringUtils.isBlank(m.getOpenid())){
            m.setOpenid(p.getOpenid());
            m.setOpenidTime(new Date());
            patientDao.save(m);
        }

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

@ -0,0 +1,234 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.security.AccessToken;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.AccessTokenService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.util.SystemConf;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
/**
 * Created by Reece on 2017/7/28/028.
 * 患者支付
 */
@Service
public class PatientPrescriptionPayService extends BaseService {
    private Logger logger = LoggerFactory.getLogger(PatientPrescriptionPayService.class);
    //公共配置文件
    Properties systemConf = SystemConf.getInstance().getSystemProperties();
    //    各环境对应配置
    @Value("${server.server_url}")
    private String serverUrl;
    
    //    Java配置文件 后续删除
    private String signType = "MD5";
    private String encryptType = "AES";
    
    @Value("${wechat.appId}")
    private String appId;
    @Value("${wechat.appSecret}")
    private String appSecret;
    @Value("${wechat.accId}")
    private String accId;
    
    //    引入实例
    @Autowired
    private Configure config;
    
    @Autowired
    private ChargeDao chargeDao;
    
    @Autowired
    private SignFamilyDao signFamilyDao;
    
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    
    @Autowired
    private AccessTokenService accessTokenService;
    
    @Autowired
    private com.yihu.wlyy.util.HttpUtil HttpUtil;
    
    
    public String getSignFamilyPayResult(String outChargeNo, String accessToken, String appId, String appSecret) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
//      ***************************  测通流程 ***************************************
        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.setTransType(config.getChargeQueryType());
        
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outChargeNo", outChargeNo);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
        
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
//              ***************************  测通流程 ***************************************
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response = JSON.toJSONString(res);
        
            if (OnepayDefaultClient.isSuccessful(res)) {
                //业务处理*******************
//                只返回业务出参
                result = JSON.toJSONString(res.getParam());
            
//                logger.info("请求成功,返回参数: " + result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
    
        //type = 3易联众接口保存http日志
//        logger.info("api - " + config.getChargeQueryType());
//        logger.info("request - " + msgBody);
//        logger.info("responses - " + response);
//        logger.info("error - " + error);
        if (!isSuccess) {
            throw new Exception(error);
        }
    
        return result;
    }
    
    /**
     * 1.根据时间范围遍历没有医保签约号的家庭签约支付记录
     * 2.询家庭签约支付结果,补更新医保签约号
     * @param startdate
     * @param enddate
     */
    public void getSignFamilyPayResultJob(Date startdate, Date enddate) throws Exception {
    
        //根据时间范围遍历没有医保签约号的家庭签约支付记录
        List<WlyyCharge> charges = chargeDao.findByTradeStatusAndMiRegisterNoAndUpdateTime(0,enddate,startdate);
        
        if(!charges.isEmpty()){
    
            logger.info("根据时间范围遍历没有医保签约号的家庭签约支付记录:"+charges.size()+"条");
            String accessToken = this.getAccessToken();
            for (WlyyCharge charge:charges) {
                try {
                    
                    //1.根据签约ID获取家庭签约记录,判断是否有效
                    SignFamily signFamily = signFamilyDao.findByCode(charge.getChargeRelation());
                    
                    if(1 == signFamily.getStatus()){
                        HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
                        String appid = hospitalMapping.getAppId();
                        String appsecert =  hospitalMapping.getAppSecret();
                        String signFamilyPayResultJson = this.getSignFamilyPayResult(charge.getCode(),"",appid,appsecert);
                        
                        if(StringUtils.isNotBlank(signFamilyPayResultJson)){
                            JSONObject reobj =  JSON.parseObject(signFamilyPayResultJson);
                            if(reobj.containsKey("responseContent")){
                                JSONObject responseContent = reobj.getJSONObject("responseContent");
                                
                                if(responseContent.containsKey("miRegisterNo") && StringUtils.isNotBlank(responseContent.getString("miRegisterNo"))){
                                        String miRegisterNo = responseContent.getString("miRegisterNo");
                                    charge.setMiRegisterNo(miRegisterNo);
                                    charge.setNeedUpload("1");
                                    charge.setUpdateTime(new Date());
                                    chargeDao.save(charge);
                                }else{
                                    logger.info("ERROR======获取家庭签约支付医保签约号JOB,CODE:"+charge.getCode()+",message:miRegisterNo不存在");
                                }
                            
                            }else{
                                logger.info("ERROR======获取家庭签约支付医保签约号JOB,CODE:"+charge.getCode()+",message:responseContent不存在");
                            }
                        }else{
                            logger.info("ERROR======获取家庭签约支付医保签约号JOB,CODE:"+charge.getCode()+",message:接口无返回值");
                        }
                        
                    }else{
                        logger.info("ERROR======获取家庭签约支付医保签约号JOB,CODE:"+charge.getCode()+",message:对应的签约记录无效");
                    }
                    
                }catch (Exception e){
                    logger.info("ERROR======获取家庭签约支付医保签约号JOB,CODE:"+charge.getCode()+",message:" +e.getMessage());
                    continue;
                }
            }
        }
    }
    /**
     * 获取微信的access_token
     *
     * @return
     */
    public String getAccessToken() throws Exception{
        Iterable<AccessToken> accessTokens = accessTokenService.findAccessToken();
        if (accessTokens != null) {
            for (AccessToken accessToken : accessTokens) {
                if ((System.currentTimeMillis() - accessToken.getAdd_timestamp()) < (accessToken.getExpires_in() * 1000)) {
                    return accessToken.getAccess_token();
                } else {
                    accessTokenService.delAccessToken(accessToken);
                    break;
                }
            }
        }
        String token_url = "https://api.weixin.qq.com/cgi-bin/token";
        String params = "grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
        String result = HttpUtil.sendGet(token_url, params);
        org.json.JSONObject json = new org.json.JSONObject(result);
        if (json.has("access_token")) {
            String token = json.get("access_token").toString();
            String expires_in = json.get("expires_in").toString();
            AccessToken newaccessToken = new AccessToken();
            newaccessToken.setAccess_token(token);
            newaccessToken.setExpires_in(Long.parseLong(expires_in));
            newaccessToken.setAcc_id(accId);
            accessTokenService.addAccessToken(newaccessToken);
            return token;
        } else {
            return null;
        }
    }
}

+ 31 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.message.MessageDao;
@ -18,16 +19,19 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MessageType;
import net.sf.json.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/7/27.
@ -56,7 +60,8 @@ public class PrescriptionService extends BaseService {
    private JwPrescriptionService jwPrescriptionService;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private DoctorTeamDao doctorTeamDao;
    @Autowired
@ -97,6 +102,31 @@ public class PrescriptionService extends BaseService {
        }
    }
    /**
     * 设置处方redis药品信息
     * @param prescriptionCode
     * @return
     */
    public boolean setPrescriptionInfo(String prescriptionCode){
        try {
            if(!StringUtils.isEmpty(prescriptionCode))
            {
                //判断该续方的药品信息redis是否存在
                String key = "prescription:"+prescriptionCode+":drugInfo";
                List<PrescriptionInfo> list = prescriptionInfoDao.findByPrescriptionCode(prescriptionCode);
                if(list!=null&&list.size()>0){
                    String re = JSONArray.fromObject(list).toString();
                    redisTemplate.opsForValue().set(key,re,180, TimeUnit.DAYS);
                }
            }
        }
        catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
        return true;
    }
    /**
     * 配药完成
     * @param code

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

@ -488,6 +488,7 @@ public class FamilyContractService extends BaseService {
            p.setTownName(townName);
            p.setAddress(address);
            p.setOpenid(openid);
            p.setOpenidTime(new Date());
            p.setIdcard(idcard);
            p.setMobile(mobile);
            p.setSsc(ssc);

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

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

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

@ -437,10 +437,10 @@ public class PushMsgTask {
                m.put("remark", keyword4);
            } else if (type == 9) {
                temp.setUrl(url + "jkjy/html/article.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                //默认是推送本地数据库文章,如有传url说明是集美宣教系统推送文章
                //如果是ArticleUrl不为空,那就说明是外部系统推送文章(如:集美宣教)
                String articleUrl = json.has("articleUrl") ? json.getString("articleUrl") : null;
                if(StringUtils.isNotEmpty(articleUrl)){
                    temp.setUrl(articleUrl+"?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(articleUrl);
                }
                temp_id = template_healthy_article;
                temp.setTemplate_id(temp_id);

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

@ -521,4 +521,21 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /**
     *立即执行:查询家庭签约支付结果,补更新医保签约号
     *@author huangwenjie
     *@date 2017/9/29 13:37
     */
    @RequestMapping(value = "/executeSignFamilyPayResultJob", method = RequestMethod.POST)
    @ApiOperation("立即执行查询家庭签约支付结果,补更新医保签约号")
    public String executeSignFamilyPayResultJob() {
        try {
            quartzHelper.startNow(SignFamilyPayResultJob.class, "SIGN_FAMILY_PAY_RESULT_MIRESISTERNO_JOB", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

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

@ -87,8 +87,8 @@ sfexpress_reorder_job=0 0/10 * * * ?
#同步智业字典
zy_dict_job=0 0 1 * * ?
#遍历支付成功,院内结算失败的的记录,重新结算,10分钟跑一次
zy_execute_sick_settle_job=0 0/10 * * * ?
#遍历支付成功,院内结算失败的的记录,重新结算,3分钟跑一次
zy_execute_sick_settle_job=0 0/3 * * * ?
#处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
prescription_pay_query_job=0 0/3 * * * ?
@ -101,6 +101,9 @@ doctor_feldsher_template_job=0 0/29 * * * ?
# 病患者定标情况同步JOB (每天2点一次)
patient_disease_contion_syn_job=0 0 2 * * ?
#查询家庭签约支付结果,补更新医保签约号,3分钟跑一次
sign_family_pay_result_migisterno_job=0 0/3 * * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html

BIN
patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx


BIN
patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美对外测试服务器信息.docx


+ 12 - 0
patient-co/patient-co-wlyy/pom.xml

@ -436,6 +436,18 @@
            <artifactId>elasticsearch-sql</artifactId>
            <version>2.4.1.0</version>
        </dependency>
        <!--elasticsearch start-->
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>2.4.4</version>
        </dependency>
        <dependency>
            <groupId>io.searchbox</groupId>
            <artifactId>jest</artifactId>
            <version>2.4.0</version>
        </dependency>
        <!--elasticsearch end-->
    </dependencies>
    <build>
        <finalName>wlyy</finalName>

+ 93 - 93
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElasticFactory.java

@ -1,93 +1,93 @@
//package com.yihu.wlyy.config.es;
//
//import io.searchbox.client.JestClient;
//import io.searchbox.client.JestClientFactory;
//import io.searchbox.client.config.HttpClientConfig;
//import org.elasticsearch.client.Client;
//import org.elasticsearch.client.transport.TransportClient;
//import org.elasticsearch.common.settings.Settings;
//import org.elasticsearch.common.transport.InetSocketTransportAddress;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//import org.springframework.util.StringUtils;
//
//import javax.annotation.PostConstruct;
//import java.net.InetAddress;
//import java.net.UnknownHostException;
//import java.util.concurrent.TimeUnit;
//
///**
// * Created by chenweida on 2017/6/5.
// */
//@Component
//public class ElasticFactory {
//    private static JestClientFactory factory = null;
//
//    @Value("${es.host}")
//    private String esHost;
//    @Value("${es.port}")
//    private String port;
//    @Value("${es.tPort}")
//    private String tPort;
//    @Value("${es.clusterName}")
//    private String clusterName;
////-----------------------------------jestClient----------------------------------------
//
//    /**
//     * @param "http://localhost:9200"
//     * @return
//     */
//    @PostConstruct
//    public JestClient getJestClient() {
//        synchronized (ElasticFactory.class) {
//            if (factory == null) {
//                //初始化链接
//                init();
//            }
//        }
//        return factory.getObject();
//    }
//
//    /**
//     * 初始化链接
//     */
//    public synchronized void init() {
//
//        // Construct a new Jest client according to configuration via factory
//        factory = new JestClientFactory();
//        factory.setHttpClientConfig(new HttpClientConfig
//                .Builder("http://" + esHost + ":" + port)
//                .multiThreaded(true)
//                .maxTotalConnection(50)// 最大链接
//                .maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间
//                .connTimeout(30000)
//                .discoveryEnabled(true)
//                .readTimeout(30000)//30秒
//                .build());//得到链接
//    }
//
//    //-----------------------------------TransportClient----------------------------------------
//    private Client transportClient;
//
//    public Client getTransportClient() {
//        try {
//            initTranClient();
//            return transportClient;
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return null;
//    }
//
//    private synchronized void initTranClient() throws UnknownHostException {
//        if (transportClient == null) {
//            Settings settings = Settings.settingsBuilder()
//                    .put("client.transport.sniff", true)//开启嗅探功能
//                    .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
//                    .build();
//
//            transportClient = TransportClient.builder().settings(settings).build()
//                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esHost), Integer.valueOf(tPort)));
//        }
//    }
//}
package com.yihu.wlyy.config.es;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.config.HttpClientConfig;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/6/5.
 */
@Component
public class ElasticFactory {
    private static JestClientFactory factory = null;
    @Value("${es.host}")
    private String esHost;
    @Value("${es.port}")
    private String port;
    @Value("${es.tPort}")
    private String tPort;
    @Value("${es.clusterName}")
    private String clusterName;
//-----------------------------------jestClient----------------------------------------
    /**
     * @param "http://localhost:9200"
     * @return
     */
    @PostConstruct
    public JestClient getJestClient() {
        synchronized (ElasticFactory.class) {
            if (factory == null) {
                //初始化链接
                init();
            }
        }
        return factory.getObject();
    }
    /**
     * 初始化链接
     */
    public synchronized void init() {
        // Construct a new Jest client according to configuration via factory
        factory = new JestClientFactory();
        factory.setHttpClientConfig(new HttpClientConfig
                .Builder("http://" + esHost + ":" + port)
                .multiThreaded(true)
                .maxTotalConnection(50)// 最大链接
                .maxConnectionIdleTime(120, TimeUnit.SECONDS)//链接等待时间
                .connTimeout(30000)
                .discoveryEnabled(true)
                .readTimeout(30000)//30秒
                .build());//得到链接
    }
    //-----------------------------------TransportClient----------------------------------------
    private Client transportClient;
    public Client getTransportClient() {
        try {
            initTranClient();
            return transportClient;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    private synchronized void initTranClient() throws UnknownHostException {
        if (transportClient == null) {
            Settings settings = Settings.settingsBuilder()
                    .put("client.transport.sniff", true)//开启嗅探功能
                    .put("cluster.name", StringUtils.isEmpty(clusterName) ? "jkzl" : clusterName)//默认集群名字是jkzl
                    .build();
            transportClient = TransportClient.builder().settings(settings).build()
                    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(esHost), Integer.valueOf(tPort)));
        }
    }
}

+ 49 - 49
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java

@ -1,49 +1,49 @@
//package com.yihu.wlyy.config.es;
//
//import io.searchbox.client.JestClient;
//import io.searchbox.core.Bulk;
//import io.searchbox.core.BulkResult;
//import io.searchbox.core.Index;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Scope;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
//;
//
///**
// * Created by chenweida on 2017/6/2.
// */
//@Component
//@Scope("prototype")
//public class ElastricSearchSave {
//
//    private Logger logger = LoggerFactory.getLogger(ElastricSearchSave.class);
//    @Autowired
//    private ElasticFactory elasticFactory;
//
//    public Boolean save(List  sms,String esIndex,String esType) {
//        try {
//            //得到链接
//            JestClient jestClient = elasticFactory.getJestClient();
//
//            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
//            for (Object obj : sms) {
//                Index index = new Index.Builder(obj).build();
//                bulk.addAction(index);
//            }
//            BulkResult br = jestClient.execute(bulk.build());
//            logger.info("save data count:" + sms.size());
//            logger.info("save flag:" + br.isSucceeded());
//            return br.isSucceeded();
//        } catch (Exception e) {
//            e.printStackTrace();
//            logger.error(" save error :" + e.getMessage());
//        }
//        return null;
//    }
//
//}
package com.yihu.wlyy.config.es;
import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.List;
;
/**
 * Created by chenweida on 2017/6/2.
 */
@Component
@Scope("prototype")
public class ElastricSearchSave {
    private Logger logger = LoggerFactory.getLogger(ElastricSearchSave.class);
    @Autowired
    private ElasticFactory elasticFactory;
    public Boolean save(List  sms,String esIndex,String esType) {
        try {
            //得到链接
            JestClient jestClient = elasticFactory.getJestClient();
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (Object obj : sms) {
                Index index = new Index.Builder(obj).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
            logger.info("save data count:" + sms.size());
            logger.info("save flag:" + br.isSucceeded());
            return br.isSucceeded();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(" save error :" + e.getMessage());
        }
        return null;
    }
}

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

@ -1,16 +1,12 @@
package com.yihu.wlyy.interceptors;
import com.yihu.wlyy.util.CodeFomat;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Map;
@ -43,6 +39,7 @@ public class EncodingFilter implements Filter {
                newRequest.addParameter(key, URLDecoder.decode((value),"utf-8"));
            }
        }
        logger.info(" reqURL:"+request.getRequestURI());
        chain.doFilter(newRequest, response);
    }

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/httplog/HttpLogDetailDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.repository.httplog;
import com.yihu.wlyy.entity.httpLog.HttpLogDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/9/26.
 */
public interface HttpLogDetailDao extends PagingAndSortingRepository<HttpLogDetail, Long>, JpaSpecificationExecutor<HttpLogDetail> {
}

+ 30 - 30
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientHealthGuidanceDao.java

@ -1,6 +1,6 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.patient;
@ -18,43 +18,43 @@ import com.yihu.wlyy.entity.patient.PatientHealthGuidance;
public interface PatientHealthGuidanceDao extends PagingAndSortingRepository<PatientHealthGuidance, Long>, JpaSpecificationExecutor<PatientHealthGuidance> {
	@Query("select b.name, b.photo, a.id, a.content, a.createTime,b.level,a.readStatus from PatientHealthGuidance a, Doctor b where a.patient = ?1 and a.doctor = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByPatient(String patient, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.createTime,b.level,a.readStatus from PatientHealthGuidance a, Doctor b where a.patient = ?1 and a.doctor = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByPatient(String patient, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, a.content, a.createTime,b.level,a.readStatus from PatientHealthGuidance a, Doctor b where a.patient = ?1 and a.doctor = b.code and a.id < ?2 and a.del = '1' order by a.id desc")
	Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
	
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, Pageable pageRequest);
	
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.id < ?2 and a.patient = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, long id, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.createTime,b.level,a.readStatus from PatientHealthGuidance a, Doctor b where a.patient = ?1 and a.doctor = b.code and a.id < ?2 and a.del = '1' order by a.id desc")
    Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.patient = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, String patient, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.patient = b.code and a.id < ?3 and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, String patient, long id, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.id < ?2 and a.patient = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, long id, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.czrq between ?2 and ?3 and a.patient = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, Date begin, Date end, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.patient = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.czrq between ?2 and ?3 and a.id < ?4 and a.patient = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, Date begin, Date end, long id, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.patient = b.code and a.id < ?3 and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, long id, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.czrq between ?3 and ?4 and a.patient = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, String patient, Date begin, Date end, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.czrq between ?2 and ?3 and a.patient = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, Date begin, Date end, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.czrq between ?3 and ?4 and a.id < ?5 and a.patient = b.code and a.del = '1' order by a.id desc")
	Page<Object> findByDoctor(String doctor, String patient, Date begin, Date end, long id, Pageable pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.czrq between ?2 and ?3 and a.id < ?4 and a.patient = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, Date begin, Date end, long id, Pageable pageRequest);
	//查找昨天的健康指导
	@Query("SELECT a FROM PatientHealthGuidance a WHERE unix_timestamp(a.czrq)>=unix_timestamp(?1) and unix_timestamp(a.czrq)<unix_timestamp(?2) ")
	List<PatientHealthGuidance> findByCzrqyYesterday(String yesterday,String now );
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.czrq between ?3 and ?4 and a.patient = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, Date begin, Date end, Pageable pageRequest);
	@Query("SELECT count(a) from PatientHealthGuidance a WHERE  a.patient=?2 and a.doctor=?1 ")
	Integer findbydoctorAndPatient(String doctor, String patientCode);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, Patient b where a.doctor = ?1 and a.patient = ?2 and a.czrq between ?3 and ?4 and a.id < ?5 and a.patient = b.code and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, Date begin, Date end, long id, Pageable pageRequest);
	@Query("select b.name, b.photo, a.id, substring(a.content, 1, 50) as content, a.createTime,b.level,b.code,a.adminTeamCode from PatientHealthGuidance a, Doctor b where a.doctor = b.code and a.patient = ?1 and a.adminTeamCode = ?2 and a.del = '1'")
	Page<Object> findByPatientAndTeamCode(String patient, Long teamCode, Pageable pageable);
    //查找昨天的健康指导
    @Query("SELECT a FROM PatientHealthGuidance a WHERE unix_timestamp(a.czrq)>=unix_timestamp(?1) and unix_timestamp(a.czrq)<unix_timestamp(?2) ")
    List<PatientHealthGuidance> findByCzrqyYesterday(String yesterday, String now);
    @Query("SELECT count(a) from PatientHealthGuidance a WHERE  a.patient=?2 and a.doctor=?1 ")
    Integer findbydoctorAndPatient(String doctor, String patientCode);
    @Query("select b.name, b.photo, a.id, substring(a.content, 1, 50) as content, a.createTime,b.level,b.code,a.adminTeamCode from PatientHealthGuidance a, Doctor b where a.doctor = b.code and a.patient = ?1 and a.adminTeamCode = ?2 and a.del = '1'")
    Page<Object> findByPatientAndTeamCode(String patient, Long teamCode, Pageable pageable);
}

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

@ -1,20 +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();
//}
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' order by a.inspectionStartTime asc")
    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 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanLibraryDao.java

@ -1,20 +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);
//
//}
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 order by a.endDay asc ")
    List<PrenatalInspectorPlanLibrary> findByDays(Long endDay);
}

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

@ -1,17 +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);
//}
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);
}

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

@ -415,4 +415,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query(" select a from SignFamily a where a.patient = ?1 ")
    SignFamily findPatientExpensesStatus(String patient);
    // 查询团队已签约的总数
    @Query("select count(1) from SignFamily a where  a.adminTeamId = ?1 and (a.status = 1 or a.status = 2) and a.type = 2")
    int countAmountSignedByAdminTeam(Long id);
}

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

@ -1,155 +1,442 @@
//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();
package com.yihu.wlyy.service.app.prenatalInspector;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
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.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.third.jw.JwMaternalChildService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
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.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;
import java.util.Map;
/**
 * 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;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private JwMaternalChildService jwMaternalChildService;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private ZyDictService zyDictService;
//    public
    /**
     * 待产检计划
     * @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.add(json);
        }
        return jsonArray;
    }
    /**
     * 获取产检列表
     * @param patientCode
     * @return
     */
    public JSONArray getEhrMaternalFirstExamRecord(String patientCode){
        JSONArray re = new JSONArray();
        SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
        String hospital = null;
        if(signFamily!=null){
            hospital = signFamily.getHospital();
        }
        Patient patient = patientDao.findByCode(patientCode);
        try{
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(),hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                for (int i=0;i<data.size();i++) {
                    JSONObject planJson = new JSONObject();
                    JSONObject pregnancy = data.getJSONObject(i);
                    String PREGNANCY_NO = pregnancy.getString("PREGNANCY_NO");//智业产检号
                    String END_MANNER = pregnancy.getString("END_MANNER");//妊娠终止方式
                    String END_TIME = pregnancy.getString("END_TIME");//结束妊娠
                    String MENSES_LAST = pregnancy.getString("MENSES_LAST");//末次月经
                    String EXPECTED_TIME = pregnancy.getString("EXPECTED_TIME");//预产期
                    String DELIVERY_WAY = pregnancy.getString("DELIVERY_WAY");//分娩方式
                    String DELIVERY_TIME = pregnancy.getString("DELIVERY_TIME");//分娩方式时间
                    String EXAM_TIME = pregnancy.getString("EXAM_TIME");//检查日期
                    planJson.put("pregnancyNo",PREGNANCY_NO);
                    planJson.put("endManner",END_MANNER);
                    planJson.put("endTime",END_TIME);
                    planJson.put("mensesLast",MENSES_LAST);
                    planJson.put("expectedTime",EXPECTED_TIME);
                    Date date = new Date();
                    if(StringUtils.isBlank(END_TIME)){
                        //未结束妊娠,生成待产检计划
                        List<PrenatalInspectorPlan> plans = prenatalInspectorPlanDao.findByCode(PREGNANCY_NO);
                        if(plans==null||plans.size()==0){//判断是否已经生成产检记录
                            //获取最后一次检查时间-查询复检记录
                            String lastExamTime = getLastExamTime(patient.getIdcard(),hospital,PREGNANCY_NO);
                            if(StringUtils.isBlank(lastExamTime)){
                                lastExamTime = EXAM_TIME;
                            }
                            Date lastMenstrualDate = DateUtil.strToDate(MENSES_LAST);
                            Long days = DateUtil.getDays(date,lastMenstrualDate);
                            days = days>365?0:days;//老早前的测试数据处理
                            List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
                            plans = new ArrayList<>();
                            PrenatalInspectorPlan plan = null;
                            for (PrenatalInspectorPlanLibrary library:libraries){
                                Date startTime = DateUtil.getPrenatalInspectorDate(lastMenstrualDate,library.getStartDay().intValue());
                                Long temp = DateUtil.getDays(DateUtil.strToDateLong(lastExamTime),startTime);
                                if(temp>0){//说明已经产检
                                    continue;
                                }
                                plan = new PrenatalInspectorPlan();
                                plan.setInspectionPhase(library.getInspectionPhase());
                                plan.setStatus("0");
                                plan.setPatient(patientCode);
                                plan.setCzrq(date);
                                plan.setCheckItem(library.getCheckItem());
                                plan.setInspectionCode(PREGNANCY_NO);//产检号
                                plan.setInspectionEndTime(DateUtil.getPrenatalInspectorDate(lastMenstrualDate,library.getEndDay().intValue()));
                                plan.setInspectionStartTime(startTime);
                                plan.setName(library.getName());
                                plan.setThisFocus(library.getThisFocus());
                                plan.setThisNote(library.getThisNote());
                                if("1".equals(plan.getInspectionPhase())&&signFamily!=null){
                                    plan.setSignHospital(signFamily.getHospital());
                                }
                                plans.add(plan);
                            }
                            if (plans.size()>0){
                                prenatalInspectorPlanDao.save(plans);
                            }
                        }
                        //计算距离下次产检时间
                        Long nextExamDay = 0l;
                        for (PrenatalInspectorPlan plan:plans) {
                            Long temp = DateUtil.getDays(date,plan.getInspectionStartTime());
                            if(nextExamDay==0||nextExamDay>temp){
                                nextExamDay = temp;
                            }
                        }
                        planJson.put("plans",plans);//待产检列表
                        planJson.put("nextExamDay",nextExamDay);//距离下次产检天数
                        //产床预约信息
                        String precontract_org_name = "";//产床医院
                        try {
                            String bedRecode = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(patient.getIdcard(),hospital);
                            JSONObject bedJson = JSONObject.parseObject(bedRecode);
                            JSONArray bedData = null;
                            if(bedJson.getInteger("status")==200){
                                bedData = json.getJSONObject("data").getJSONArray("DATA");
                            }
                            if(bedData!=null&&bedData.size()>0){
                                JSONObject exam = data.getJSONObject(data.size()-1);
                                precontract_org_name = exam.getString("PRECONTRACT_ORG_NAME");
                            }
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                        planJson.put("precontractOrgName",precontract_org_name);//产床医院
                    }
                    re.add(planJson);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return re;
    }
    /**
     * 初检
     * @param patientCode
     * @return
     */
    public JSONObject firstExam(String patientCode,String pregnancyNo){
        JSONObject re = new JSONObject();
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String hospital = null;
            if(signFamily!=null){
                hospital = signFamily.getHospital();
            }
            Patient patient = patientDao.findByCode(patientCode);
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(),hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                for (int i=0;i<data.size();i++){
                    if(pregnancyNo.equals(data.getJSONObject(i).getString("PREGNANCY_NO"))){//判断是否同一个产检
                        re = data.getJSONObject(i);
                        return re;
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return re;
    }
    /**
     * 复检记录
     * @param patientCode
     * @return
     */
    public String reExamRecode(String patientCode,String pregnancyNo){
        String re = "";
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String hospital = null;
            if(signFamily!=null){
                hospital = signFamily.getHospital();
            }
            Patient patient = patientDao.findByCode(patientCode);
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(patient.getIdcard(),hospital,pregnancyNo);
            return response;
        }catch (Exception e){
            e.printStackTrace();
        }
        return re;
    }
    /**
     * 获取最后一次产检时间
     * @param idcard
     * @param hospital
     * @return
     */
    public String getLastExamTime(String idcard,String hospital,String pregnancyNo){
        String re = "";
        try {
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(idcard,hospital,pregnancyNo);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                JSONObject exam = data.getJSONObject(data.size()-1);
                String PREGNANCY_WEEK = exam.getString("PREGNANCY_WEEK");//检查孕周
                String examTime = exam.getString("EXAM_TIME");//产检日期
                re = examTime;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return re;
    }
    /**
     * 产床预约信息
     * @param idcard
     * @param hospital
     * @return
     */
    public String getEhrMaternalBedPrecontractRecord(String idcard,String hospital){
        String re = "";
        try {
            String response = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(idcard,hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                JSONObject exam = data.getJSONObject(data.size()-1);
                String PREGNANCY_WEEK = exam.getString("PREGNANCY_WEEK");//检查孕周
                String examTime = exam.getString("EXAM_TIME");//产检日期
                re = examTime;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return re;
    }
    /**
     * 预建卡列表-孕检计划
     * @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.add(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;
    }
    /**
     * 上传预建卡
     * @param code
     */
    public void uploadPreExam(String code){
        try {
            //上传预建卡
            jwMaternalChildService.SaveEhrMaternalPreFirstExamRecord(code);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 新建产检预建卡
     */
    @Transactional
    public String addPrenatalInspectorPreCard(PrenatalInspectorPreCard preCard,String patientcCode){
        SignFamily signFamily = signFamilyDao.findByPatient(patientcCode);
        if(signFamily==null){
            return "-1";
        }
        //获取团队长
        Doctor doctor = doctorDao.findByAdminTeamId(signFamily.getAdminTeamId());
        preCard.setDoctor(doctor.getCode());
        preCard.setDoctorName(doctor.getName());
        //保存智业的医生信息
        Map<String,Object> map = zyDictService.findJwDoctorByDoctor(doctor.getCode());
        if(map!=null){
            preCard.setJwDoctor(map.get("jw_doctor").toString());
        }
        String re = "";
        //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);
//
        preCard.setDel("1");
        preCard.setCode(getCode());
        preCard.setCzrq(date);
        preCard.setDueDate(DateUtil.getDueDate(preCard.getLastMenstrualDate()));//预产期
        preCard.setStatus("0");
        preCard.setEffective("");
        preCard.setInspectionPhase("1");//检查阶段
        preCard.setUploadStatus("0");//未上传
        prenatalInspectorPreCardDao.save(preCard);
//        String patient = preCard.getPatient();
//
//        //2、生成待产检计划
        //2.更新居民信息
//        Patient p = patientDao.findByCode(patient);
//        p.setName(preCard.getName());
//        p.setSsc(preCard.getSsc());
//        p.setBirthday(preCard.getBirthday());
//        p.setMobile(preCard.getMobile());
        return preCard.getCode();
        //2、生成待产检计划(待产检计划由获取健康信息接口生成,关联产检计划)
//        Long days = DateUtil.getDays(date,lastMenstrualDate);
//        List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
//        List<PrenatalInspectorPlan> plans = new ArrayList<>();
@ -180,61 +467,63 @@
//        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();
//            }
//        }
//
//    }
//
//}
    }
    /**
     * 产检提醒(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());
                    org.json.JSONObject json = new org.json.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.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.sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                    }
                }
            }catch (Exception e){
                System.out.println("微信提醒发送失败");
                e.printStackTrace();
            }
        }
    }
}

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

@ -1348,7 +1348,69 @@ public class PatientPrescriptionPayService extends BaseService {
        return result;
    }
    
    public String getSignFamilyPayResult(String outChargeNo, String accessToken, String appId, String appSecret) throws Exception {
        int flag = 0;
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
//      ***************************  测通流程 ***************************************
        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.setTransType(config.getChargeQueryType());
        
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outChargeNo", outChargeNo);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
        
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
//              ***************************  测通流程 ***************************************
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response = JSON.toJSONString(res);
        
            if (OnepayDefaultClient.isSuccessful(res)) {
                //业务处理*******************
//                只返回业务出参
                flag = 1;
                result = JSON.toJSONString(res.getParam());
            
                logger.info("请求成功,返回参数: " + result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
    
        //type = 3易联众接口保存http日志
        logger.info("api - " + config.getChargeQueryType());
        logger.info("request - " + msgBody);
        logger.info("responses - " + response);
        logger.info("error - " + error);
        if (!isSuccess) {
            throw new Exception(error);
        }
    
        return result;
    }
}

+ 88 - 84
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -231,97 +231,101 @@ public class PrescriptionService extends BaseService {
            if(200 == status && 1 == code){
                JSONArray zyCfinfoListReturnData = zyCfinfo.getJSONArray("returnData");
                JSONArray zyCfinfoList = zyCfinfoListReturnData.getJSONArray(0);
                JSONArray cfInfo = new JSONArray();
                for (int i = 0; i < zyCfinfoList.size(); i++) {
                    JSONObject zyCfinfoObj = zyCfinfoList.getJSONObject(i);
                    //支付明细
                    JSONArray zySettleDetailList = zyCfinfoList.getJSONObject(i).getJSONArray("SETTLE_DETAIL");
                    //根据挂号号获取处方明细
                    Prescription prescription = prescriptionDao.findByVisitNoAndRecipeNo(zyCfinfoObj.getString("VISIT_NO"),recipeNo);
                    List<PrescriptionDiagnosis> pds = prescriptionDiagnosisDao.findByPrescriptionCode(prescription.getCode());
                    //诊断明细        {"zdms00":"诊断或症状描述","zdbh00":"诊断或症状编码"}
                    if (!pds.isEmpty()){
                        JSONArray zdInfo = new JSONArray();
                        for (PrescriptionDiagnosis pd : pds) {
                            JSONObject j1 = new JSONObject();
                            j1.put("zdms00",pd.getName());//诊断或症状描述"1型糖尿病性酮症"
                            j1.put("zdbh00",pd.getCode());//诊断或症状编码"E10.100"
                            zdInfo.add(j1);
                
                if(zyCfinfoListReturnData.size()!=0 && !zyCfinfoListReturnData.isEmpty()){
    
                    JSONArray zyCfinfoList = zyCfinfoListReturnData.getJSONArray(0);
                    JSONArray cfInfo = new JSONArray();
                    for (int i = 0; i < zyCfinfoList.size(); i++) {
        
                        JSONObject zyCfinfoObj = zyCfinfoList.getJSONObject(i);
                        //支付明细
                        JSONArray zySettleDetailList = zyCfinfoList.getJSONObject(i).getJSONArray("SETTLE_DETAIL");
                        //根据挂号号获取处方明细
                        Prescription prescription = prescriptionDao.findByVisitNoAndRecipeNo(zyCfinfoObj.getString("VISIT_NO"),recipeNo);
        
                        List<PrescriptionDiagnosis> pds = prescriptionDiagnosisDao.findByPrescriptionCode(prescription.getCode());
                        //诊断明细        {"zdms00":"诊断或症状描述","zdbh00":"诊断或症状编码"}
                        if (!pds.isEmpty()){
                            JSONArray zdInfo = new JSONArray();
                            for (PrescriptionDiagnosis pd : pds) {
                                JSONObject j1 = new JSONObject();
                                j1.put("zdms00",pd.getName());//诊断或症状描述"1型糖尿病性酮症"
                                j1.put("zdbh00",pd.getCode());//诊断或症状编码"E10.100"
                                zdInfo.add(j1);
                            }
                            json.put("zdlist",zdInfo);
                        }
                        json.put("zdlist",zdInfo);
                    }
                    //收费明细       {"xmgg00":"项目规格","cfhao0":"处方号","sfybxm":"是否医保项目","dcyydw":"单次用药单位","xmje00":"项目金额","xmbh00":"项目编号",
                    // "ysxm00":"医生姓名","yppl00":"药品频率","gytj00":"给药途径","ypts00":"药品天数","xmdj00":"项目单价","qyzl00":"取药总量","ylts00":"药量天数",
                    // "sptxbm":"商品条形编码","xmmc00":"项目名称","fpxmbh":"发票项目编号","xmsl00":"项目数量","ypyl00":"药品用量","qyzldw":"取药单位","xmdw00":"项目单位",
                    // "jx0000":"剂型"}
                    Integer cfxms0 = 0;
                    for (int j= 0; j < zySettleDetailList.size(); j++) {
                        JSONObject zySettleDetailObj = zySettleDetailList.getJSONObject(j);
        
        
                        //收费明细       {"xmgg00":"项目规格","cfhao0":"处方号","sfybxm":"是否医保项目","dcyydw":"单次用药单位","xmje00":"项目金额","xmbh00":"项目编号",
                        // "ysxm00":"医生姓名","yppl00":"药品频率","gytj00":"给药途径","ypts00":"药品天数","xmdj00":"项目单价","qyzl00":"取药总量","ylts00":"药量天数",
                        // "sptxbm":"商品条形编码","xmmc00":"项目名称","fpxmbh":"发票项目编号","xmsl00":"项目数量","ypyl00":"药品用量","qyzldw":"取药单位","xmdw00":"项目单位",
                        // "jx0000":"剂型"}
        
                        Integer cfxms0 = 0;
                        for (int j= 0; j < zySettleDetailList.size(); j++) {
                            JSONObject zySettleDetailObj = zySettleDetailList.getJSONObject(j);
//                        String RECIPE_NO = zySettleDetailObj.getString("RECIPE_NO");
//                        if(recipeNo.equals(RECIPE_NO)){//过滤其他处方号
                        cfxms0++;
                        JSONObject j2 = new JSONObject();
                        j2.put("xmbh00",zySettleDetailObj.getString("INSUR_ITEM_CODE"));//项目编号
                        j2.put("xmmc00",zySettleDetailObj.getString("INSUR_ITEM_NAME"));//项目名称
                        j2.put("fpxmbh",zySettleDetailObj.getString("INSUR_INVOICE_TYPE_CODE"));//发票项目编号
                        j2.put("sfybxm",zySettleDetailObj.getString("INSUR_FLAG"));//是否医保项目
                        Double _price = Double.parseDouble(zySettleDetailObj.getString("INSUR_ITEM_PRICE"));
                        DecimalFormat df = new DecimalFormat("######0.00");
                        _price = _price*100;
                        j2.put("xmdj00",df.format(_price));//项目单价
                        j2.put("xmdw00",zySettleDetailObj.getString("INSUR_ITEM_UNIT_NAME"));//项目单位
                        j2.put("xmgg00",zySettleDetailObj.getString("INSUR_ITEM_SPEC"));//项目规格(医保)
                        j2.put("xmsl00",zySettleDetailObj.getString("ITEM_QUANTITY"));//项目数量
                        Double _cost = Double.parseDouble(zySettleDetailObj.getString("COST"));
                        Integer infocost = CommonUtil.doubleToInt(_cost);
                        j2.put("xmje00",String.valueOf(infocost));//项目金额
                        j2.put("ysxm00",zySettleDetailObj.getString("APPLY_OPERATOR_NAME"));//医生姓名
                        j2.put("sptxbm","");//商品条形编码
                        j2.put("yppl00",zySettleDetailObj.getString("FREQUENCY"));//药品频率
                        j2.put("ypyl00",zySettleDetailObj.getString("PHYSIC_DOSE"));//药品用量
                        j2.put("cfhao0",zySettleDetailObj.getString("RECIPE_NO"));//处方号
                        j2.put("jx0000",zySettleDetailObj.getString("PHYSIC_FORM"));//剂型
                        j2.put("dcyydw",zySettleDetailObj.getString("PHYSIC_DOSE_UNIT"));//单次用药单位
                        j2.put("qyzl00",zySettleDetailObj.getString("PHYSIC_AMOUNT"));//取药总量
                        j2.put("qyzldw",zySettleDetailObj.getString("PHYSIC_AMOUNT_UNIT"));//取药单位
                        j2.put("gytj00",zySettleDetailObj.getString("PHYSIC_USAGE"));//给药途径
                        j2.put("ypts00",zySettleDetailObj.getString("DAY_COUNT"));//药品天数
                        cfInfo.add(j2);
                            cfxms0++;
                            JSONObject j2 = new JSONObject();
                            j2.put("xmbh00",zySettleDetailObj.getString("INSUR_ITEM_CODE"));//项目编号
                            j2.put("xmmc00",zySettleDetailObj.getString("INSUR_ITEM_NAME"));//项目名称
                            j2.put("fpxmbh",zySettleDetailObj.getString("INSUR_INVOICE_TYPE_CODE"));//发票项目编号
                            j2.put("sfybxm",zySettleDetailObj.getString("INSUR_FLAG"));//是否医保项目
            
                            Double _price = Double.parseDouble(zySettleDetailObj.getString("INSUR_ITEM_PRICE"));
                            DecimalFormat df = new DecimalFormat("######0.00");
                            _price = _price*100;
                            j2.put("xmdj00",df.format(_price));//项目单价
            
                            j2.put("xmdw00",zySettleDetailObj.getString("INSUR_ITEM_UNIT_NAME"));//项目单位
                            j2.put("xmgg00",zySettleDetailObj.getString("INSUR_ITEM_SPEC"));//项目规格(医保)
                            j2.put("xmsl00",zySettleDetailObj.getString("ITEM_QUANTITY"));//项目数量
            
                            Double _cost = Double.parseDouble(zySettleDetailObj.getString("COST"));
                            Integer infocost = CommonUtil.doubleToInt(_cost);
                            j2.put("xmje00",String.valueOf(infocost));//项目金额
            
                            j2.put("ysxm00",zySettleDetailObj.getString("APPLY_OPERATOR_NAME"));//医生姓名
                            j2.put("sptxbm","");//商品条形编码
                            j2.put("yppl00",zySettleDetailObj.getString("FREQUENCY"));//药品频率
                            j2.put("ypyl00",zySettleDetailObj.getString("PHYSIC_DOSE"));//药品用量
                            j2.put("cfhao0",zySettleDetailObj.getString("RECIPE_NO"));//处方号
                            j2.put("jx0000",zySettleDetailObj.getString("PHYSIC_FORM"));//剂型
                            j2.put("dcyydw",zySettleDetailObj.getString("PHYSIC_DOSE_UNIT"));//单次用药单位
                            j2.put("qyzl00",zySettleDetailObj.getString("PHYSIC_AMOUNT"));//取药总量
                            j2.put("qyzldw",zySettleDetailObj.getString("PHYSIC_AMOUNT_UNIT"));//取药单位
                            j2.put("gytj00",zySettleDetailObj.getString("PHYSIC_USAGE"));//给药途径
                            j2.put("ypts00",zySettleDetailObj.getString("DAY_COUNT"));//药品天数
                            cfInfo.add(j2);
//                        }
                        }
        
                        //处方主信息     {"yyksbm":"医生科室编号","bcsfcs":"本次收费次数","yszjhm":"医生证件号码","ysxm00":"医生姓名","mzlb00":"门诊类别","sfydgh":"是否药店挂号",
                        // "bcghcs":"本次挂号次数","ghksmc":"挂号科室名称","cfxms0":"明细上传数量","mzlsh0":"医保挂号流水号 如果为空,将自动医保挂号并收费","ghfy00":"挂号费用",
                        // "yszjdj":"医师诊金级别","bqbm00":"病情编码","sfygwd":"是否医改网点"}
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("yyksbm",zyCfinfoObj.getString("VISIT_DEPT"));//医生科室编号
                        jsonObject.put("bcsfcs","1");//本次收费次数
                        jsonObject.put("yszjhm",zyCfinfoObj.getString("VISIT_IDENTITY_CARD_NO"));//医生证件号码
                        jsonObject.put("ysxm00",prescription.getDoctorName());//医生姓名
                        jsonObject.put("mzlb00",zyCfinfoObj.getString("INSUR_DISP_REGISTER_TYPE"));//门诊类别---普通门诊默认为101
                        jsonObject.put("sfydgh","N");//是否药店挂号,默认为N,不是药店挂号
                        jsonObject.put("bcghcs","1");//本次挂号次数
                        jsonObject.put("ghksmc",prescription.getDeptName());//挂号科室名称
                        jsonObject.put("mzlsh0","");//医保挂号流水号
                        jsonObject.put("ghfy00","0");//挂号费用
                        jsonObject.put("bqbm00","");//病情编码---可为空,不传递
                        jsonObject.put("sfygwd","N");//是否医改网点--默认为否
                        jsonObject.put("yszjdj",zyCfinfoObj.getString("INSUR_DOCTOR_RANK"));//医师诊金级别
                        jsonObject.put("cfxms0",""+cfxms0);//明细上传数量
                        json.put("recipeContent",jsonObject);
                    }
                    //处方主信息     {"yyksbm":"医生科室编号","bcsfcs":"本次收费次数","yszjhm":"医生证件号码","ysxm00":"医生姓名","mzlb00":"门诊类别","sfydgh":"是否药店挂号",
                    // "bcghcs":"本次挂号次数","ghksmc":"挂号科室名称","cfxms0":"明细上传数量","mzlsh0":"医保挂号流水号 如果为空,将自动医保挂号并收费","ghfy00":"挂号费用",
                    // "yszjdj":"医师诊金级别","bqbm00":"病情编码","sfygwd":"是否医改网点"}
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("yyksbm",zyCfinfoObj.getString("VISIT_DEPT"));//医生科室编号
                    jsonObject.put("bcsfcs","1");//本次收费次数
                    jsonObject.put("yszjhm",zyCfinfoObj.getString("VISIT_IDENTITY_CARD_NO"));//医生证件号码
                    jsonObject.put("ysxm00",prescription.getDoctorName());//医生姓名
                    jsonObject.put("mzlb00",zyCfinfoObj.getString("INSUR_DISP_REGISTER_TYPE"));//门诊类别---普通门诊默认为101
                    jsonObject.put("sfydgh","N");//是否药店挂号,默认为N,不是药店挂号
                    jsonObject.put("bcghcs","1");//本次挂号次数
                    jsonObject.put("ghksmc",prescription.getDeptName());//挂号科室名称
                    jsonObject.put("mzlsh0","");//医保挂号流水号
                    jsonObject.put("ghfy00","0");//挂号费用
                    jsonObject.put("bqbm00","");//病情编码---可为空,不传递
                    jsonObject.put("sfygwd","N");//是否医改网点--默认为否
                    jsonObject.put("yszjdj",zyCfinfoObj.getString("INSUR_DOCTOR_RANK"));//医师诊金级别
                    jsonObject.put("cfxms0",""+cfxms0);//明细上传数量
                    json.put("recipeContent",jsonObject);
                    json.put("mxlist",cfInfo);
                }
                json.put("mxlist",cfInfo);
            }else{
                String errormessage = jwobj.getString("MESSAGE");
                throw new Exception(errormessage);

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

@ -347,8 +347,9 @@ public class FamilyContractService extends BaseService {
        json.put("services", services);
        //是否签约上限
        int signLimit = signWebService.getSickFamilyDoctorSignLimit(doctor);
        json.put("signLimit", signLimit);
        JSONObject signLimit = signWebService.getSickFamilyDoctorSignLimit(doctor);
        json.put("signTotal",signLimit.getInt("signTotal"));//签约总数
        json.put("limitTotal",signLimit.getInt("limitTotal"));//限制总数
        return json;
    }
@ -1721,7 +1722,14 @@ public class FamilyContractService extends BaseService {
     * @return
     */
    public int countAmountSigned(String doctor) {
        return signFamilyDao.countAmountSignedByDoctor(doctor);
        AdminTeam adminTeam = doctorAdminTeamDao.findByLeaderCode(doctor);
        if(adminTeam!=null){
            //团队长只显示实际有签约关系的数量
            return signFamilyDao.countAmountSignedByAdminTeam(adminTeam.getId());
        }else{
            //不是团队长显示所有有服务关系的数量
            return signFamilyDao.countAmountSignedByDoctor(doctor);
        }
    }
    /**
@ -4053,7 +4061,7 @@ public class FamilyContractService extends BaseService {
                "  a.patient=p.`code` " +
                " AND a.`status` IN (1, 2) ");
        List params = new ArrayList<>();
        if (teamCode!=null&&teamCode>0) {
        if (teamCode != null && teamCode > 0) {
            sb.append(" AND a.admin_team_code =?  ");
            params.add(teamCode);
        }
@ -4066,13 +4074,13 @@ public class FamilyContractService extends BaseService {
        return patients;
    }
    public String getSickArchiveFlag(String patient)throws Exception{
    public String getSickArchiveFlag(String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        String rs = jwArchivesService.getSickArchiveFlag(p.getIdcard());
        return rs ;
        return rs;
    }
    public String checkSickArchiveFlag(String idCard)throws Exception{

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

@ -2621,13 +2621,15 @@ public class SignWebService extends BaseService {
     * @param doctorCode
     * @return
     */
    public Integer getSickFamilyDoctorSignLimit(String doctorCode){
        Integer re = 0;//0未达上线 1 已达上限
    public JSONObject getSickFamilyDoctorSignLimit(String doctorCode){
        JSONObject re = new JSONObject();//0未达上线 1 已达上限
        Integer signTotal = 0;
        Integer limitTotal = 0;
        List<AdminTeam> adminTeams = doctorAdminTeamMemberDao.findDoctorTeams(doctorCode);
        int limitNum = 0;
        for(AdminTeam one:adminTeams){
            //获取团队签约数
            Integer signCount = signFamilyDao.findByAdminTeamIdAndStatus(one.getId(),0);
            signTotal+=signCount;
            //获取智业团队签约上线
            String jwCode = one.getMappingCode();//智业服务团队的code
            try{
@ -2637,18 +2639,15 @@ public class SignWebService extends BaseService {
                    com.alibaba.fastjson.JSONObject data = json.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        int sign_limit_number = data.getJSONArray("DATA").getJSONObject(0).getInteger("SIGN_LIMIT_NUMBER");//签约上线
                        if(signCount>=sign_limit_number){
                            limitNum++;
                        }
                        limitTotal+=sign_limit_number;
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if(adminTeams.size()==limitNum){
            re = 1;
        }
        re.put("signTotal",signTotal);
        re.put("limitTotal",limitTotal);
        return re;
    }

+ 180 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -0,0 +1,180 @@
package com.yihu.wlyy.service.app.statisticsES;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.quota.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
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.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
 * Created by ${liuwenbin} on 2017/9/14.
 */
@Service
public class StatisticsESService {
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private ElasticFactory elasticFactory;
    /**
     * 获取上次统计时间
     *
     * @return
     */
    public String getStatisticsTime() {
        String date = DateUtil.dateToStrLong(new Date());
        try {
//            date = redisTemplate.opsForValue().get("quota:date");
//            JestClient jestClient = elasticFactory.getJestClient();
//
//            Bulk.Builder bulk = new Bulk.Builder().defaultIndex("health_edu_article_patient_test").defaultType("health_edu_article_patient_test");
//            PrescriptionDispensaryCode ap = new PrescriptionDispensaryCode();
//            ap.setCode("aaaa");
//            ap.setType(2);
//            Index index = new Index.Builder(ap).build();
//            bulk.addAction(index);
//            BulkResult br = jestClient.execute(bulk.build());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return date;
    }
    /**
     * 获取时间戳
     *
     * @return
     */
    public String getQuotaTimeStamp() {
//        return redisTemplate.opsForValue().get("quota:timeKey");
        return "";
    }
    /**
     * 获取时间范围内按间隔统计指标增量
     *
     * @param startDate 起始时间
     * @param endDate   结束时间
     * @param interval  时间间隔
     * @param area      区域或机构代码
     * @param level     级别
     * @param index     指标
     * @return
     */
    public JSONArray getDateIncrementDetail(String startDate, String endDate, int interval, String area, String level, String index, String level2_type) throws Exception {
        if (interval == 1) {
            return dateStatistics(startDate, endDate, area, level, index, level2_type);
        } else if (interval == 2) {
//            return weekStatistics(startDate, endDate, area, level, index, level2_type);
        } else if (interval == 3) {
//            return monthStatistics(startDate, endDate, area, level, index, level2_type);
        }
        return new JSONArray();
    }
    /**
     * 按日统计
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @return
     */
    private JSONArray dateStatistics(String startDate, String endDate, String area, String level, String index, String level2_type) {
//        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
//        // 起始日期
//        Calendar start = Calendar.getInstance();
//        start.setTime(DateUtil.strToDate(startDate, DateUtil.YYYY_MM_DD));
//        //结束日期
//        Calendar end = Calendar.getInstance();
//        end.setTime(DateUtil.strToDate(endDate, DateUtil.YYYY_MM_DD));
//        // 日期集合
//        List<Calendar> days = new ArrayList<>();
//        days.add(start);
//        boolean flag = true;
//        if (startDate.compareTo(endDate) == 0) {
//            flag = false;
//        }
//         计算统计日期
//        while (flag) {
//            Calendar next = Calendar.getInstance();
//            next.setTime(days.get(days.size() - 1).getTime());
//            next.add(Calendar.DATE, 1);
//            if (df.format(next.getTime()).compareTo(endDate) < 0) {
//                days.add(next);
//            } else {
//                days.add(end);
//                flag = false;
//            }
//        }
        startDate = changeDate(startDate);
        endDate = changeDate(endDate);
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        if (SaveModel.teamLevel.equals(level)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,result1,result2 from wlyy_quota_test where team='" + area + "'");
            groupBy.append("  group by team,teamName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.OrgLevel.equals(level)) {
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where hospital='" + area + "'");
            groupBy.append("  group by hospital,hospitalName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.townLevel.equals(level)) {
            sql.append("select town,townName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where town='" + area + "'");
            groupBy.append("  group by town,townName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.cityLevel.equals(level)) {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where city='" + area + "'");
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name");
        }
        sql.append(" and quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='1'  ");
        sql.append(" and areaLevel='"+level+"'");
        sql.append(" and quotaDate>='" + startDate + "'");
        sql.append(" and quotaDate<='" + endDate + "'");
        if(StringUtils.isNotBlank(level2_type)){
            sql.append(" and slaveKey2='"+level2_type+"'");
            groupBy.append(",slaveKey2,slaveKey2Name");
        }
        sql.append(groupBy);
        List<SaveModel> list =elasticsearchUtil.excute(sql.toString(),SaveModel.class,"","");
        List<JSONObject> result = new ArrayList<>();
        for (SaveModel saveModel:list){
            JSONObject range = new JSONObject();
            range.put("range", saveModel.getQuotaDate());
            range.put("amount", saveModel.getResult1());
            result.add(range);
        }
        return new JSONArray(result);
    }
    /**
     * 时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
     *
     * @param quotaDate
     */
    private String changeDate(String quotaDate) {
        return quotaDate + "T00:00:00+0800";
    }
}

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

@ -126,7 +126,6 @@ public class DoctorService extends TokenService {
            sql += " and level = ? ";
            args.add(level);
        }
        sql += " limit " + (page * pagesize) + "," + pagesize;
        List<Doctor> doctorList = jdbcTemplate.query(sql, args.toArray(), new BeanPropertyRowMapper(Doctor.class));

+ 24 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/httplog/LogService.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.service.third.httplog;
import com.yihu.wlyy.entity.httpLog.HttpLog;
import com.yihu.wlyy.entity.httpLog.HttpLogDetail;
import com.yihu.wlyy.repository.httplog.HttpLogDao;
import com.yihu.wlyy.repository.httplog.HttpLogDetailDao;
import com.yihu.wlyy.service.system.SystemDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -17,7 +19,8 @@ public class LogService {
    @Autowired
    private HttpLogDao httpLogDao;
    @Autowired
    private HttpLogDetailDao httpLogDetailDao;
    @Autowired
    private SystemDictService systemDictService;
@ -42,11 +45,18 @@ public class LogService {
            log.setMethod(method);
            log.setParams(params);
            log.setCreateTime(new Date());
            log.setCreateTime(new Date());
            log.setResponse(response);
            log.setError(error);
//            log.setResponse(response);
//            log.setError(error);
            log.setStatus(isSuccess?"1":"0");
            httpLogDao.save(log);
            //明细表
            HttpLogDetail detail = new HttpLogDetail();
            detail.setCode(log.getId());
            detail.setCreateTime(new Date());
            detail.setResponse(response);
            detail.setError(error);
            httpLogDetailDao.save(detail);
        }
        catch (Exception ex)
        {
@ -73,10 +83,18 @@ public class LogService {
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
                log.setResponse(response);
                log.setError(error);
//                log.setResponse(response);
//                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                //明细表
                HttpLogDetail detail = new HttpLogDetail();
                detail.setCode(log.getId());
                detail.setCreateTime(new Date());
                detail.setResponse(response);
                detail.setError(error);
                httpLogDetailDao.save(detail);
            }
        }
        catch (Exception ex)

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

@ -0,0 +1,305 @@
package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by yeshijie on 2017/9/25.
 */
@Service
public class JwMaternalChildService {
    private static final Logger logger = LoggerFactory.getLogger(JwMaternalChildService.class);
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 获取孕妇建卡信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalFirstExamRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalFirstExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取非第一次产检记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param pregnancyNo 产检号
     * @return
     * @throws Exception
     */
    public String getEhrMaternalReExamRecord(String idcard,String hospital,String pregnancyNo) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalReExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("pregnancyNo", pregnancyNo));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取产床预约信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalBedPrecontractRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalBedPrecontractRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取高危产妇信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPregnancyHighRecord( String idcard, String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalPregnancyHighRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取孕妇分娩信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryRecord(String idcard, String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalDeliveryRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取新生儿基本信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryChildRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalDeliveryChildRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取儿童健康体检0-6岁记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildMedicalRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalChildMedicalRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取新生儿访视信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalHomeVisitRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalHomeVisitRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取新生儿免疫记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildImmuneRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalChildImmuneRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取孕妇预建卡信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPreFirstExamRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalPreFirstExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 上传孕妇预建卡信息
     * @param code 预建卡code
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalPreFirstExamRecord(String code) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/SaveEhrMaternalPreFirstExamRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("code", code));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 上传新生儿访视信息
     * @param idcard 身份证
     * @param hospital 医院code
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalHomeVisitRecord(String idcard,String hospital) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/SaveEhrMaternalHomeVisitRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取待产记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param searchTime 查询时间
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSPreDeliveryRecord(String idcard,String hospital,String searchTime) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalZSPreDeliveryRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("searchTime", searchTime));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取阴道分娩记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param searchTime 查询时间
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSDeliveryRecord(String idcard, String hospital, String searchTime) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalZSDeliveryRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("searchTime", searchTime));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取剖宫产记录
     * @param idcard 身份证
     * @param hospital 医院code
     * @param searchTime 查询时间
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSCaesareanBirthRecord(String idcard, String hospital, String searchTime) throws Exception{
        String url = jwUrl + "/third/prenatalInspector/getEhrMaternalZSCaesareanBirthRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", idcard));
        params.add(new BasicNameValuePair("hospital", hospital));
        params.add(new BasicNameValuePair("searchTime", searchTime));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
}

+ 204 - 201
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -1,201 +1,204 @@
//package com.yihu.wlyy.util;
//
//import com.alibaba.druid.sql.ast.SQLExpr;
//import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
//import com.alibaba.druid.sql.parser.SQLExprParser;
//import com.yihu.wlyy.config.es.ElasticFactory;
//import org.elasticsearch.action.search.SearchResponse;
//import org.nlpcn.es4sql.domain.Select;
//import org.nlpcn.es4sql.jdbc.ObjectResult;
//import org.nlpcn.es4sql.jdbc.ObjectResultsExtractor;
//import org.nlpcn.es4sql.parse.ElasticSqlExprParser;
//import org.nlpcn.es4sql.parse.SqlParser;
//import org.nlpcn.es4sql.query.AggregationQueryAction;
//import org.nlpcn.es4sql.query.DefaultQueryAction;
//import org.nlpcn.es4sql.query.SqlElasticSearchRequestBuilder;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by chenweida on 2017/7/17.
// * SELECT town,townName,sum(result1) result1 FROM wlyy_quota_test
// * where quotaCode='1'
// * group by town,townName , date_histogram(field='quotaDate','interval'='week')
// */
//@Component
//public class ElasticsearchUtil {
//
//    private Logger logger = LoggerFactory.getLogger(ElasticsearchUtil.class);
//
//    @Autowired
//    private ElasticFactory elasticFactory;
//
//    public List excute(String sql, Class clazz, String esType, String esIndex) {
//        List saveModels = new ArrayList<>();
//        try {
//            SQLExprParser parser = new ElasticSqlExprParser(sql);
//            SQLExpr expr = parser.expr();
//            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
//
//            Select select = null;
//            select = new SqlParser().parseSelect(queryExpr);
//
//            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
//            AggregationQueryAction action = null;
//            DefaultQueryAction queryAction = null;
//            SqlElasticSearchRequestBuilder requestBuilder = null;
//            if (select.isAgg) {
//                //包含计算的的排序分组的
//                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
//                requestBuilder = action.explain();
//            } else {
//                //封装成自己的Select对象
//                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
//                requestBuilder = queryAction.explain();
//            }
//            SearchResponse response = (SearchResponse) requestBuilder.get();
//            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getAggregations(), true);
//            List<String> heads = temp.getHeaders();
//            temp.getLines().stream().forEach(one -> {
//                Object saveModel = null;
//                try {
//                    saveModel = clazz.newInstance();
//                } catch (Exception e) {
//                    logger.error(e.getMessage());
//                }
//                for (int i = 0; i < one.size(); i++) {
//                    try {
//                        String key = null;
//                        Object value = one.get(i);
//                        if (heads.get(i).contains("date_histogram")) {
//                            key = "setQuotaDate";
//                            value = DateUtil.strToDate(String.valueOf(value), "yyyy-MM-dd HH:mm:ss");
//                        } else {
//                            key = "set" + UpFirstStr(heads.get(i));
//                        }
//
//                        if (value instanceof String) {
//                            clazz.getMethod(key, String.class).invoke(saveModel, value);
//                        } else if (value instanceof Integer) {
//                            clazz.getMethod(key, Integer.class).invoke(saveModel, value);
//                        } else if (value instanceof Double) {
//                            clazz.getMethod(key, Integer.class).invoke(saveModel, ((Double) value).intValue());
//                        } else if (value instanceof java.util.Date) {
//                            clazz.getMethod(key, java.util.Date.class).invoke(saveModel, value);
//                        }
//                    } catch (Exception e) {
//                        logger.warn(e.getMessage());
//                    }
//                }
//                saveModels.add(saveModel);
//            });
//        } catch (Exception e) {
//            logger.error(e.getMessage());
//        }
//        return saveModels;
//    }
//
//    public Long excuteForLong(String sql, String esType, String esIndex) {
//        try {
//            SQLExprParser parser = new ElasticSqlExprParser(sql);
//            SQLExpr expr = parser.expr();
//            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
//
//            Select select = null;
//            select = new SqlParser().parseSelect(queryExpr);
//
//            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
//            AggregationQueryAction action = null;
//            DefaultQueryAction queryAction = null;
//            SqlElasticSearchRequestBuilder requestBuilder = null;
//            if (select.isAgg) {
//                //包含计算的的排序分组的
//                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
//                requestBuilder = action.explain();
//            } else {
//                //封装成自己的Select对象
//                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
//                requestBuilder = queryAction.explain();
//            }
//            SearchResponse response = (SearchResponse) requestBuilder.get();
//            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getAggregations(), true);
//            Long Longvalue = ((Double) temp.getLines().get(0).get(1)).longValue();
//            return Longvalue;
//        } catch (Exception e) {
//            logger.error(e.getMessage());
//        }
//        return 0L;
//    }
//
//    /**
//     * 首字母大写
//     *
//     * @param str
//     * @return
//     */
//    private String UpFirstStr(String str) {
//        return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase());
//    }
//
//    public Object excuteOneObject(String sql, Class clazz, String esType, String esIndex) {
//        try {
//            SQLExprParser parser = new ElasticSqlExprParser(sql);
//            SQLExpr expr = parser.expr();
//            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
//
//            Select select = null;
//            select = new SqlParser().parseSelect(queryExpr);
//
//            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
//            AggregationQueryAction action = null;
//            DefaultQueryAction queryAction = null;
//            SqlElasticSearchRequestBuilder requestBuilder = null;
//            if (select.isAgg) {
//                //包含计算的的排序分组的
//                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
//                requestBuilder = action.explain();
//            } else {
//                //封装成自己的Select对象
//                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
//                requestBuilder = queryAction.explain();
//            }
//            SearchResponse response = (SearchResponse) requestBuilder.get();
//            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getHits(), true);
//            List<String> heads = temp.getHeaders();
//            Object saveModel = clazz.newInstance();
//            try {
//                for (int i = 0; i < temp.getLines().get(0).size(); i++) {
//                    String key = null;
//                    Object value = temp.getLines().get(0).get(i);
//                    if (heads.get(i).contains("createTime")) {
//                        key = "setCreateTime";
//                        value = DateUtil.strToDate(String.valueOf(value).replace("+0800","").replace("T"," "), "yyyy-MM-dd HH:mm:ss");
//                    } else {
//                        key = "set" + UpFirstStr(heads.get(i));
//                    }
//
//                    if (value instanceof String) {
//                        clazz.getMethod(key, String.class).invoke(saveModel, value);
//                    } else if (value instanceof Integer) {
//                        clazz.getMethod(key, Integer.class).invoke(saveModel, value);
//                    } else if (value instanceof Double) {
//                        clazz.getMethod(key, Integer.class).invoke(saveModel, ((Double) value).intValue());
//                    } else if (value instanceof java.util.Date) {
//                        clazz.getMethod(key, java.util.Date.class).invoke(saveModel, value);
//                    }
//                }
//            } catch (Exception e) {
//                logger.warn(e.getMessage());
//            }
//            return saveModel;
//        } catch (Exception e) {
//            logger.error(e.getMessage());
//        }
//        return null;
//    }
//}
package com.yihu.wlyy.util;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.expr.SQLQueryExpr;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.yihu.wlyy.config.es.ElasticFactory;
import org.elasticsearch.action.search.SearchResponse;
import org.nlpcn.es4sql.domain.Select;
import org.nlpcn.es4sql.jdbc.ObjectResult;
import org.nlpcn.es4sql.jdbc.ObjectResultsExtractor;
import org.nlpcn.es4sql.parse.ElasticSqlExprParser;
import org.nlpcn.es4sql.parse.SqlParser;
import org.nlpcn.es4sql.query.AggregationQueryAction;
import org.nlpcn.es4sql.query.DefaultQueryAction;
import org.nlpcn.es4sql.query.SqlElasticSearchRequestBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/7/17.
 * SELECT town,townName,sum(result1) result1 FROM wlyy_quota_test
 * where quotaCode='1'
 * group by town,townName , date_histogram(field='quotaDate','interval'='week')
 */
@Component
public class ElasticsearchUtil {
    private Logger logger = LoggerFactory.getLogger(ElasticsearchUtil.class);
    @Autowired
    private ElasticFactory elasticFactory;
    public List excute(String sql, Class clazz, String esType, String esIndex) {
        List saveModels = new ArrayList<>();
        try {
            SQLExprParser parser = new ElasticSqlExprParser(sql);
            SQLExpr expr = parser.expr();
            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
            Select select = null;
            select = new SqlParser().parseSelect(queryExpr);
            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
            AggregationQueryAction action = null;
            DefaultQueryAction queryAction = null;
            SqlElasticSearchRequestBuilder requestBuilder = null;
            if (select.isAgg) {
                //包含计算的的排序分组的
                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = action.explain();
            } else {
                //封装成自己的Select对象
                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = queryAction.explain();
            }
            SearchResponse response = (SearchResponse) requestBuilder.get();
            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getHits(), true);
            List<String> heads = temp.getHeaders();
            temp.getLines().stream().forEach(one -> {
                Object saveModel = null;
                try {
                    saveModel = clazz.newInstance();
                } catch (Exception e) {
                    logger.error(e.getMessage());
                }
                for (int i = 0; i < one.size(); i++) {
                    try {
                        String key = null;
                        Object value = one.get(i);
                        if(heads.get(i).startsWith("_")){
                            continue;
                        }
                        if (heads.get(i).contains("date_histogram")) {
                            key = "setQuotaDate";
                            value = DateUtil.strToDate(String.valueOf(value), "yyyy-MM-dd HH:mm:ss");
                        } else {
                            key = "set" + UpFirstStr(heads.get(i));
                        }
                        if (value instanceof String) {
                            clazz.getMethod(key, String.class).invoke(saveModel, value);
                        } else if (value instanceof Integer) {
                            clazz.getMethod(key, Integer.class).invoke(saveModel, value);
                        } else if (value instanceof Double) {
                            clazz.getMethod(key, Integer.class).invoke(saveModel, ((Double) value).intValue());
                        } else if (value instanceof java.util.Date) {
                            clazz.getMethod(key, java.util.Date.class).invoke(saveModel, value);
                        }
                    } catch (Exception e) {
                        logger.warn(e.getMessage());
                    }
                }
                saveModels.add(saveModel);
            });
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return saveModels;
    }
    public Long excuteForLong(String sql, String esType, String esIndex) {
        try {
            SQLExprParser parser = new ElasticSqlExprParser(sql);
            SQLExpr expr = parser.expr();
            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
            Select select = null;
            select = new SqlParser().parseSelect(queryExpr);
            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
            AggregationQueryAction action = null;
            DefaultQueryAction queryAction = null;
            SqlElasticSearchRequestBuilder requestBuilder = null;
            if (select.isAgg) {
                //包含计算的的排序分组的
                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = action.explain();
            } else {
                //封装成自己的Select对象
                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = queryAction.explain();
            }
            SearchResponse response = (SearchResponse) requestBuilder.get();
            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getAggregations(), true);
            Long Longvalue = ((Double) temp.getLines().get(0).get(1)).longValue();
            return Longvalue;
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return 0L;
    }
    /**
     * 首字母大写
     *
     * @param str
     * @return
     */
    private String UpFirstStr(String str) {
        return str.replaceFirst(str.substring(0, 1), str.substring(0, 1).toUpperCase());
    }
    public Object excuteOneObject(String sql, Class clazz, String esType, String esIndex) {
        try {
            SQLExprParser parser = new ElasticSqlExprParser(sql);
            SQLExpr expr = parser.expr();
            SQLQueryExpr queryExpr = (SQLQueryExpr) expr;
            Select select = null;
            select = new SqlParser().parseSelect(queryExpr);
            //通过抽象语法树,封装成自定义的Select,包含了select、from、where group、limit等
            AggregationQueryAction action = null;
            DefaultQueryAction queryAction = null;
            SqlElasticSearchRequestBuilder requestBuilder = null;
            if (select.isAgg) {
                //包含计算的的排序分组的
                action = new AggregationQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = action.explain();
            } else {
                //封装成自己的Select对象
                queryAction = new DefaultQueryAction(elasticFactory.getTransportClient(), select);
                requestBuilder = queryAction.explain();
            }
            SearchResponse response = (SearchResponse) requestBuilder.get();
            ObjectResult temp = new ObjectResultsExtractor(true, true, true).extractResults(response.getHits(), true);
            List<String> heads = temp.getHeaders();
            Object saveModel = clazz.newInstance();
            try {
                for (int i = 0; i < temp.getLines().get(0).size(); i++) {
                    String key = null;
                    Object value = temp.getLines().get(0).get(i);
                    if (heads.get(i).contains("createTime")) {
                        key = "setCreateTime";
                        value = DateUtil.strToDate(String.valueOf(value).replace("+0800","").replace("T"," "), "yyyy-MM-dd HH:mm:ss");
                    } else {
                        key = "set" + UpFirstStr(heads.get(i));
                    }
                    if (value instanceof String) {
                        clazz.getMethod(key, String.class).invoke(saveModel, value);
                    } else if (value instanceof Integer) {
                        clazz.getMethod(key, Integer.class).invoke(saveModel, value);
                    } else if (value instanceof Double) {
                        clazz.getMethod(key, Integer.class).invoke(saveModel, ((Double) value).intValue());
                    } else if (value instanceof java.util.Date) {
                        clazz.getMethod(key, java.util.Date.class).invoke(saveModel, value);
                    }
                }
            } catch (Exception e) {
                logger.warn(e.getMessage());
            }
            return saveModel;
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return null;
    }
}

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

@ -578,11 +578,11 @@ public class DoctorController extends BaseController {
                // 二维码地址
                json.put("qrcode", temp.getQrcode());
                // 审核总数
                json.put("signed_amount", familyContractService.countAmountSigned(getUID()));
                json.put("signed_amount", familyContractService.countAmountSigned(code));
                // 等审核总数
                json.put("unsign_amount", familyContractService.countAmountUnsign(getUID()));
                json.put("unsign_amount", familyContractService.countAmountUnsign(code));
                // 咨询统计
                Map<String, Long> consultCount = consultTeamService.getAllCount(getUID());
                Map<String, Long> consultCount = consultTeamService.getAllCount(code);
                // 咨询总数
                json.put("consultAmount", consultCount.get("all"));
                // 当天咨询数

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

@ -78,6 +78,8 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    /**
     * 查询
@ -600,8 +602,6 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
    /**********************************福州健康文章接口********************************************/
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    @RequestMapping(value = "getDoctorArticalList",method = RequestMethod.GET)
    @ApiOperation("获取健康教育文章列表")

+ 71 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prenatalInspector/PrenatalController.java

@ -0,0 +1,71 @@
package com.yihu.wlyy.web.doctor.prenatalInspector;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.app.prenatalInspector.PrenatalInspectorPreCardService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2017/9/27.
 */
@RestController
@RequestMapping(value = "/doctor/prenatalnspector", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "居民端-产检")
public class PrenatalController extends BaseController{
    @Autowired
    private PrenatalInspectorPreCardService preCardService;
    @ApiOperation("建卡列表-孕检计划")
    @RequestMapping(value = "prenatalInspectorList", method = RequestMethod.POST)
    public String prenatalInspectorList(@ApiParam(name = "patient", value = "居民code", defaultValue = "d9de442323324a759ac82857c4692184")
                                        @RequestParam(value = "patient", required = true) String patient){
        try {
            JSONArray jsonArray = preCardService.getEhrMaternalFirstExamRecord(patient);
            return write(200, "查询成功!", "list", jsonArray);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("初检检查")
    @RequestMapping(value = "getEhrMaternalFirstExamRecord", method = RequestMethod.GET)
    public String getEhrMaternalFirstExamRecord(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
                                                @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo,
                                                @ApiParam(name = "patient", value = "居民code", defaultValue = "d9de442323324a759ac82857c4692184")
                                                @RequestParam(value = "patient", required = true) String patient){
        try {
            JSONObject jsonObject = preCardService.firstExam(patient,pregnancyNo);
            return write(200, "查询成功!", "data", jsonObject);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("复检检查记录")
    @RequestMapping(value = "getEhrMaternalReExamRecord", method = RequestMethod.GET)
    public String getEhrMaternalReExamRecord(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
                                             @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo,
                                             @ApiParam(name = "patient", value = "居民code", defaultValue = "d9de442323324a759ac82857c4692184")
                                             @RequestParam(value = "patient", required = true) String patient){
        try {
            String response = preCardService.reExamRecode(patient,pregnancyNo);
            return response;
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
}

+ 30 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/HealthEduArticleController.java

@ -8,10 +8,12 @@ import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.service.app.health.HealthEduArticlePatientService;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.third.fzzb.HealthEducationArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.htmlparser.Parser;
import org.htmlparser.util.ParserException;
@ -50,6 +52,8 @@ public class HealthEduArticleController extends BaseController {
    private HealthEduArticleService healthEduArticleService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private HealthEducationArticleService healthEducationArticleService;
    /**
     * 查询文章列表
@ -210,5 +214,31 @@ public class HealthEduArticleController extends BaseController {
        }
    }
    /**********************************福州健康文章接口********************************************/
    @RequestMapping(value = "getDoctorArticalByUserId",method = RequestMethod.GET)
    @ApiOperation("获取医生发表的文章列表")
    public String getDoctorArticalByUserId(@ApiParam(name = "doctorCode", value = "医生code")
                                           @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                           @ApiParam(name = "articleTitle", value = "文章标题")
                                           @RequestParam(value = "articleTitle", required = false) String articleTitle,
                                           @ApiParam(name = "articleState", value = "文章状态(1、正常、2删除 3、草稿)")
                                           @RequestParam(value = "articleState", required = true) Integer articleState,
                                           @ApiParam(name = "firstLevelCategoryId", value = "一级类别ID ,多个逗号隔开")
                                           @RequestParam(value = "firstLevelCategoryId", required = false) String firstLevelCategoryId,
                                           @ApiParam(name = "pageIndex", value = "起始页数 0开始,默认0")
                                           @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                           @ApiParam(name = "pageSize", value = "每页显示数 ,默认5")
                                           @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,doctorCode);
//            com.alibaba.fastjson.JSONArray response = healthEducationArticleService.getDoctorArticalByUserId(articleTitle,articleState,firstLevelCategoryId,pageIndex,pageSize,"0de7295862dd11e69faffa163e8aee56");
            return write(200,"查询成功!","data",response);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}

Разлика између датотеке није приказан због своје велике величине
+ 122 - 78
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/PrenatalInspectorContoller.java


+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java

@ -114,6 +114,29 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            return error(-1, "获取失败!");
        }
    }
    
    /**
     * 查询家庭签约支付结果
     * @return
     */
    @RequestMapping(value = "/getSignFamilyPayResult", method = RequestMethod.GET)
    @ApiOperation(value = "查询家庭签约支付结果")
    public String getSignFamilyPayResult(
            @RequestParam(required = true)
            @ApiParam(value = "支付应用流水号", name = "outChargeNo") String outChargeNo,
            @RequestParam(required = true)
            @ApiParam(value = "易联众appid", name = "appId") String appId,
            @RequestParam(required = true)
            @ApiParam(value = "易联众app secret", name = "appSecret") String appSecret) throws Exception {
        try {
            String accessToken = getAccessToken();
            String result = payService.getSignFamilyPayResult(outChargeNo, accessToken,appId,appSecret);
            return write(200, "获取成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败!");
        }
    }
    /**

+ 312 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/quota/vo/SaveModel.java

@ -0,0 +1,312 @@
package com.yihu.wlyy.web.quota.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.searchbox.annotations.JestId;
import org.springframework.data.annotation.CreatedDate;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by chenweida on 2017/6/1.
 */
public class SaveModel {
    private final static String teamKey = "team";
    private final static String OrgKey = "hospital";
    private final static String townKey = "town";
    private final static String cityKey = "city";
    public final static String interval_day="1";
    public final static String interval_week="2";
    public final static String interval_month="3";
    public final static String teamLevel = "5";
    public final static String OrgLevel = "4";
    public final static String townLevel = "3";
    public final static String cityLevel = "2";
    private static final Map<String, String> fieldsSithch = new HashMap<>();
    @JestId
    private String id;
    private String saasId;//saasId
    private String quotaCode;//指标code
    private Date quotaDate;//统计时间
    private String city;//城市代码 350200
    private String cityName;//
    private String town;//区代码 350206
    private String townName;//
    private String hospital;//机构code
    private String hospitalName;//
    private String team;//团队的code
    private String teamName;//
    private String slaveKey1;//从维度  1级维度
    private String slaveKey1Name;
    private String slaveKey2;//从维度  2级维度
    private String slaveKey2Name;
    private String slaveKey3;//从维度  3级维度
    private String slaveKey3Name;
    private String slaveKey4;//从维度  4级维度
    private String slaveKey4Name;
    private Integer result1 = 0;//统计结果
    private Integer result2 = 0;//统计结果
    private String areaLevel;// 1 省 2 市 3 区县 4 机构 5团队
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd'T'HHmmss.SSS'Z'")
    @CreatedDate
    private Date createTime;//创建时间
    private String timeLevel;// 1日 2年
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd ")
    public Date getQuotaDate() {
        return quotaDate;
    }
    public void setQuotaDate(Date quotaDate) {
        this.quotaDate = quotaDate;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    //@Field(type = FieldType.String, analyzer="ngram_analyzer")//使用ngram进行单字分词
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getTeam() {
        return team;
    }
    public void setTeam(String team) {
        this.team = team;
    }
    public String getSlaveKey1() {
        return slaveKey1;
    }
    public void setSlaveKey1(String slaveKey1) {
        this.slaveKey1 = slaveKey1;
    }
    public String getSlaveKey2() {
        return slaveKey2;
    }
    public void setSlaveKey2(String slaveKey2) {
        this.slaveKey2 = slaveKey2;
    }
    public String getSlaveKey3() {
        return slaveKey3;
    }
    public void setSlaveKey3(String slaveKey3) {
        this.slaveKey3 = slaveKey3;
    }
    public String getSlaveKey4() {
        return slaveKey4;
    }
    public void setSlaveKey4(String slaveKey4) {
        this.slaveKey4 = slaveKey4;
    }
    public Integer getResult1() {
        return result1;
    }
    public void setResult1(Integer result1) {
        this.result1 = result1;
    }
    public Integer getResult2() {
        return result2;
    }
    public void setResult2(Integer result2) {
        this.result2 = result2;
    }
    public String getSlaveKey1Name() {
        return slaveKey1Name;
    }
    public void setSlaveKey1Name(String slaveKey1Name) {
        this.slaveKey1Name = slaveKey1Name;
    }
    public String getSlaveKey2Name() {
        return slaveKey2Name;
    }
    public void setSlaveKey2Name(String slaveKey2Name) {
        this.slaveKey2Name = slaveKey2Name;
    }
    public String getSlaveKey3Name() {
        return slaveKey3Name;
    }
    public void setSlaveKey3Name(String slaveKey3Name) {
        this.slaveKey3Name = slaveKey3Name;
    }
    public String getSlaveKey4Name() {
        return slaveKey4Name;
    }
    public void setSlaveKey4Name(String slaveKey4Name) {
        this.slaveKey4Name = slaveKey4Name;
    }
    public String getCityName() {
        return cityName;
    }
    public void setCityName(String cityName) {
        this.cityName = cityName;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getTeamName() {
        return teamName;
    }
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    public String getQuotaCode() {
        return quotaCode;
    }
    public void setQuotaCode(String quotaCode) {
        this.quotaCode = quotaCode;
    }
    public String getAreaLevel() {
        return areaLevel;
    }
    public void setAreaLevel(String areaLevel) {
        this.areaLevel = areaLevel;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getTimeLevel() {
        return timeLevel;
    }
    public void setTimeLevel(String timeLevel) {
        this.timeLevel = timeLevel;
    }
    /**
     * 根据级别得到key
     * 1 省 2 市 3 区县 4 机构 5团队
     *
     * @param level
     * @return
     */
    public static String getAreaLevelKey(String level) {
        switch (level) {
            case teamLevel: {
                return teamKey;
            }
            case OrgLevel: {
                return OrgKey;
            }
            case townLevel: {
                return townKey;
            }
            case cityLevel: {
                return cityKey;
            }
            default: {
                return teamKey;
            }
        }
    }
}

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.app.statisticsES.StatisticsESService;
import com.yihu.wlyy.util.Constant;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ValueComparator;
@ -34,6 +35,8 @@ public class StatisticsController extends BaseController {
    @Autowired
    StatisticsService statisticsService;
    @Autowired
    StatisticsESService statisticsESService;
    @Autowired
    StatisticsAllService statisticsAllService;
    /**
@ -70,7 +73,7 @@ public class StatisticsController extends BaseController {
                                @RequestParam(required = true) String endDate,
                                @RequestParam(required = true) int interval,
                                @RequestParam(required = true) String area,
                                @RequestParam(required = true) int level,
                                @RequestParam(required = true) String level,
                                @RequestParam(required = true) String index,
                                @RequestParam(required = false) String level2_type) {
        String tag = "";
@ -80,7 +83,8 @@ public class StatisticsController extends BaseController {
            if (index != null) {
                for (String idx : indexes) {
                    result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx, level2_type));
                    result.put("index_" + idx, statisticsESService.getDateIncrementDetail(startDate, endDate, interval, area, level, idx, level2_type));
//                    result.put("index_" + idx, statisticsService.getDateIncrementDetail(startDate, endDate, interval, area, Integer.parseInt(level), idx, level2_type));
                }
            }

+ 215 - 213
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java

@ -1,213 +1,215 @@
//package com.yihu.wlyy.web.third.gateway.controller.doctor;
//
//import com.yihu.es.entity.HealthEduArticlePatient;
//import com.yihu.wlyy.entity.patient.Patient;
//import com.yihu.wlyy.service.app.consult.ConsultService;
//import com.yihu.wlyy.service.common.account.PatientService;
//import com.yihu.wlyy.task.PushMsgTask;
//import com.yihu.wlyy.util.DateUtil;
//import com.yihu.wlyy.util.ImUtill;
//import com.yihu.wlyy.web.WeixinBaseController;
//import com.yihu.wlyy.web.third.gateway.service.GcEduArticleService;
//import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
//import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
//import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
//import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
//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.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.http.MediaType;
//import org.springframework.jms.core.JmsTemplate;
//import org.springframework.jms.core.MessageCreator;
//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 javax.jms.JMSException;
//import javax.jms.Message;
//import javax.jms.Session;
//import javax.jms.TextMessage;
//import java.util.*;
//
///**
// * Created by chenweida on 2017/8/30.
// */
//@Controller
//@RequestMapping(value = "/wlyygc/doctor/edu/article", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//@ResponseBody
//@Api(description = "医生文章相关服务")
//public class GcEduArticleController extends WeixinBaseController {
//    private Logger logger = LoggerFactory.getLogger(GcEduArticleController.class);
//
//    @Autowired
//    private WeiXinOpenIdUtils weiXinOpenIdUtils;
//    @Autowired
//    private PushMsgTask pushMsgTask;
//    @Autowired
//    private PatientService patientService;
//    @Autowired
//    private ConsultService consultService;
//    @Autowired
//    private GcEduArticleService gcEduArticleService;
//    @Autowired
//    private StringRedisTemplate redisTemplate;
//    @Autowired
//    private JmsTemplate jmsTemplate;
//    @Value("${activemq.queue.healtHarticleQueue}")
//    private String channelName;
//
//    /**
//     * @param doctorCode
//     * @param page
//     * @param pagesize
//     * @return
//     */
//    @RequestMapping(value = "logs", method = RequestMethod.GET)
//    @ApiOperation("查询医生给患者推送记录 ")
//    public ResultPageListModel<HealthEduArticlePatientModel> getPatientHealthLogs(
//            @ApiParam(name = "articleType", value = "文章类别", required = false) @RequestParam(value = "articleType", required = false) String articleType,
//            @ApiParam(name = "level1Type", value = "一级分类", required = false) @RequestParam(value = "level1Type", required = false) String level1Type,
//            @ApiParam(name = "level2Type", value = "二级分类", required = false) @RequestParam(value = "level2Type", required = false) String level2Type,
//            @ApiParam(name = "level", value = "等级", required = false) @RequestParam(value = "level", required = false) String level,
//            @ApiParam(name = "doctorCode", value = "医生code,为空从useragent取", required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
//            @ApiParam(name = "patientCode", value = "接收人code", required = false) @RequestParam(value = "patientCode", required = false) String patientCode,
//            @ApiParam(name = "articleTitle", value = "文章标题", required = false) @RequestParam(value = "articleTitle", required = false) String articleTitle,
//            @ApiParam(name = "startTime", value = "开始时间yyyy-Mm-dd", required = false) @RequestParam(value = "startTime", required = false) String startTime,
//            @ApiParam(name = "endTime", value = "结束时间yyyy-Mm-dd", required = false) @RequestParam(value = "endTime", required = false) String endTime,
//            @ApiParam(name = "page", value = "当前页 起始1", required = true) @RequestParam(value = "page", required = true) Integer page,
//            @ApiParam(name = "pagesize", value = "每页显示条数", required = true) @RequestParam(value = "pagesize", required = true) Integer pagesize) {
//        try {
//            if (org.springframework.util.StringUtils.isEmpty(doctorCode)) {
//                doctorCode = getUID();
//            }
//            //最大1000
//            if (pagesize > 1000) {
//                pagesize = 1000;
//            }
//            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.getPatientHealthLogs(doctorCode, articleType, level1Type, level2Type, level, articleTitle, startTime, endTime, page, pagesize);
//            Long count = gcEduArticleService.getPatientHealthLogsCount(getUID(), articleType, level1Type, level2Type, level, articleTitle, startTime, endTime);
//            return new ResultPageListModel(
//                    page,
//                    pagesize,
//                    count.intValue()
//                    , eduArticlePatients);
//        } catch (Exception e) {
//            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
//        }
//    }
//
//    /**
//     * * 参考原来的教育文章推送
//     * http://172.19.103.88:9092/wlyy//doctor/health/edu/send?code=2e6467b5bb2f4b81b598633624d7f98e&patient=e911d1b756cd4680ab241ab76a463282&teamCode=1&attachedContent=
//     *
//     * @return
//     */
//    @RequestMapping(value = "send", method = RequestMethod.POST)
//    @ApiOperation("文章推送")
//    public BaseResultModel send(
//            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
//            @ApiParam(name = "sendCode", value = "发送人code", required = true) @RequestParam(value = "sendCode", required = true) String sendCode,
//            @ApiParam(name = "sendName", value = "发送人名", required = true) @RequestParam(value = "sendName", required = true) String sendName,
//            @ApiParam(name = "sendMessage", value = "发送人信息", required = false) @RequestParam(value = "sendMessage", required = false) String sendMessage,
//            @ApiParam(name = "teamId", value = "发送人是医生的时候,医生所属的团队", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
//            @ApiParam(name = "labelCode", value = "所选群组,多个用逗号分隔", required = true) @RequestParam(value = "labelCode", required = false, defaultValue = "") String labelCode,
//            @ApiParam(name = "labelType", value = "标签类型  1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = false) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
//            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
//            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
//            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
//            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
//            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
//            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
//            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
//            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
//            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
//            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
//            @ApiParam(name = "articleUrl", value = "宣教文章获取url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
//    ) {
//        try {
//            String[] patients = receiveCodes.split(",");//接收人的code
//            String[] unPatients = unReceiveCodes.split(",");//接收人的code
//            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
//
//            //得到需要发送的患者
//            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
//            //获取保存发送记录
//            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
//            //推送微信模板消息和发送im消息
//            new Thread(() -> {
//                //发送任务到redis
//                sender(healthEduArticlePatients);
//            }).start();
//            return new BaseResultModel();
//        } catch (Exception e) {
//            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
//        }
//    }
//
//    /**
//     * 发送到redis
//     *
//     * @param healthEduArticlePatients
//     */
//    public void sender(List<HealthEduArticlePatient> healthEduArticlePatients) {
//        //送到到队列
//        healthEduArticlePatients.stream().forEach(one -> {
//            jmsTemplate.send(channelName, new MessageCreator() {
//                @Override
//                public Message createMessage(Session session) throws JMSException {
//                    TextMessage textMessage = session.createTextMessage();
//                    textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
//                    return textMessage;
//                }
//            });
//        });
//    }
//
//    @RequestMapping(value = "sendPatients", method = RequestMethod.POST)
//    @ApiOperation("文章群推送")
//    public BaseResultModel sendPatients(
//            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = false) @RequestParam(value = "sendType", required = false,defaultValue = "2") Integer sendType,
//            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
//            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
//            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
//            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
//            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
//            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
//            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
//            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
//            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
//            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
//            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
//            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
//            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
//            @ApiParam(name = "articleUrl", value = "宣教文章获取的url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
//    ){
//        try {
//
//            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
//            //得到需要发送的患者
//            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
//            //获取保存发送记录
//            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, "", "", sendType, "", 0L, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
//            //推送微信模板消息和发送im消息
//            new Thread(() -> {
//                //发送任务到redis
//                sender(healthEduArticlePatients);
//            }).start();
//            return new BaseResultModel();
//        }catch (Exception e) {
//            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
//        }
//
//    }
//}
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.es.entity.HealthEduArticlePatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.gateway.service.GcEduArticleService;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import com.yihu.wlyy.web.third.gateway.vo.base.BaseResultModel;
import com.yihu.wlyy.web.third.gateway.vo.base.ResultPageListModel;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
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 javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.util.*;
/**
 * Created by chenweida on 2017/8/30...
 */
@Controller
@RequestMapping(value = "/wlyygc/doctor/edu/article", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
@Api(description = "医生文章相关服务")
public class GcEduArticleController extends WeixinBaseController {
    private Logger logger = LoggerFactory.getLogger(GcEduArticleController.class);
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientService patientService;
    @Autowired
    private ConsultService consultService;
    @Autowired
    private GcEduArticleService gcEduArticleService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private JmsTemplate jmsTemplate;
    @Value("${activemq.queue.healtHarticleQueue}")
    private String channelName;
    /**
     * @param doctorCode
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "logs", method = RequestMethod.GET)
    @ApiOperation("查询医生给患者推送记录 ")
    public ResultPageListModel<HealthEduArticlePatientModel> getPatientHealthLogs(
            @ApiParam(name = "articleType", value = "文章类别", required = false) @RequestParam(value = "articleType", required = false) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = false) @RequestParam(value = "level1Type", required = false) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = false) @RequestParam(value = "level2Type", required = false) String level2Type,
            @ApiParam(name = "level", value = "等级", required = false) @RequestParam(value = "level", required = false) String level,
            @ApiParam(name = "doctorCode", value = "医生code,为空从useragent取", required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(name = "patientCode", value = "接收人code", required = false) @RequestParam(value = "patientCode", required = false) String patientCode,
            @ApiParam(name = "articleTitle", value = "文章标题", required = false) @RequestParam(value = "articleTitle", required = false) String articleTitle,
            @ApiParam(name = "startTime", value = "开始时间yyyy-Mm-dd", required = false) @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间yyyy-Mm-dd", required = false) @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "page", value = "当前页 起始1", required = true) @RequestParam(value = "page", required = true) Integer page,
            @ApiParam(name = "pagesize", value = "每页显示条数", required = true) @RequestParam(value = "pagesize", required = true) Integer pagesize) {
        try {
            if (org.springframework.util.StringUtils.isEmpty(doctorCode)) {
                doctorCode = getUID();
            }
            //最大1000
            if (pagesize > 1000) {
                pagesize = 1000;
            }
            List<HealthEduArticlePatientModel> eduArticlePatients = gcEduArticleService.getPatientHealthLogs(doctorCode, articleType, level1Type, level2Type, level, articleTitle, startTime, endTime, page, pagesize);
            Long count = gcEduArticleService.getPatientHealthLogsCount(getUID(), articleType, level1Type, level2Type, level, articleTitle, startTime, endTime);
            return new ResultPageListModel(
                    page,
                    pagesize,
                    count.intValue()
                    , eduArticlePatients);
        } catch (Exception e) {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
    /**
     * * 参考原来的教育文章推送
     * http://172.19.103.88:9092/wlyy//doctor/health/edu/send?code=2e6467b5bb2f4b81b598633624d7f98e&patient=e911d1b756cd4680ab241ab76a463282&teamCode=1&attachedContent=
     *
     * @return
     */
    @RequestMapping(value = "send", method = RequestMethod.POST)
    @ApiOperation("文章推送")
    public BaseResultModel send(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "sendCode", value = "发送人code", required = true) @RequestParam(value = "sendCode", required = true) String sendCode,
            @ApiParam(name = "sendName", value = "发送人名", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "sendMessage", value = "发送人信息", required = false) @RequestParam(value = "sendMessage", required = false) String sendMessage,
            @ApiParam(name = "teamId", value = "发送人是医生的时候,医生所属的团队", required = false) @RequestParam(value = "teamId", required = false) Long teamId,
            @ApiParam(name = "labelCode", value = "所选群组,多个用逗号分隔", required = true) @RequestParam(value = "labelCode", required = false, defaultValue = "") String labelCode,
            @ApiParam(name = "labelType", value = "标签类型  1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = false) @RequestParam(value = "labelType", required = false, defaultValue = "") String labelType,
            @ApiParam(name = "receiveCodes", value = "接收人code,多个逗号分割", required = false) @RequestParam(value = "receiveCodes", required = false, defaultValue = "") String receiveCodes,
            @ApiParam(name = "unReceiveCodes", value = "不接收人code,多个逗号分割(如果同时存在receiveCodes和unReceiveCodes,也不会发送)", required = false) @RequestParam(value = "unReceiveCodes", required = false, defaultValue = "") String unReceiveCodes,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ) {
        try {
            String[] patients = receiveCodes.split(",");//接收人的code
            String[] unPatients = unReceiveCodes.split(",");//接收人的code
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
            }).start();
            return new BaseResultModel();
        } catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
    /**
     * 发送到redis
     *
     * @param healthEduArticlePatients
     */
    public void sender(List<HealthEduArticlePatient> healthEduArticlePatients) {
        //送到到队列
        healthEduArticlePatients.stream().forEach(one -> {
            jmsTemplate.send(channelName, new MessageCreator() {
                @Override
                public Message createMessage(Session session) throws JMSException {
                    TextMessage textMessage = session.createTextMessage();
                    textMessage.setText(net.sf.json.JSONObject.fromObject(one).toString());
                    return textMessage;
                }
            });
        });
    }
    @RequestMapping(value = "sendPatients", method = RequestMethod.POST)
    @ApiOperation("文章群推送")
    public BaseResultModel sendPatients(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = true) @RequestParam(value = "sendType", required = true) Integer sendType,
            @ApiParam(name = "sendCode", value = "发送人code(医生发送时,必填医生code)", required = false) @RequestParam(value = "sendCode", required = false) String sendCode,
            @ApiParam(name = "sendName", value = "发送方名称(如:卫计委发送:集美区;医生发送:医生名称)", required = true) @RequestParam(value = "sendName", required = true) String sendName,
            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取的url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, "", 0L, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
}

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

@ -61,7 +61,7 @@ public class GcLableController extends BaseController {
    @ApiOperation("根据分组类型查找标签已经标签下的患者数目")
    public ResultListModel<List<PatientLabelModel>> labelsWithNum(
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true) @RequestParam(value = "labelType", required = true) String labelType,
            @ApiParam(name = "teamCode", value = "医生所属的团队ID", required = true) @RequestParam(value = "teamCode", required = true) Long teamCode
            @ApiParam(name = "teamCode", value = "医生所属的团队ID", required = false) @RequestParam(value = "teamCode", required = false) Long teamCode
    ) {
        try {
            JSONArray result = null;
@ -125,7 +125,7 @@ public class GcLableController extends BaseController {
    @RequestMapping(value = "/unitLabels", method = RequestMethod.GET)
    @ApiOperation("根据地区查找卫计委下属单位标签")
    public ResultListModel<List<PatientLabelModel>> unitLabels(
            @ApiParam(name = "areas", value = "", required = true) @RequestParam(value = "areas", required = true) String areas
            @ApiParam(name = "areas", value = "地区code,多个地区用逗号分隔", required = true) @RequestParam(value = "areas", required = true) String areas
    ) {
        try {
            List<DictModel> dictModels = labelService.getUnitLabels(areas);

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

@ -1,328 +1,291 @@
//package com.yihu.wlyy.web.third.gateway.service;
//
//import com.yihu.wlyy.config.es.ElastricSearchSave;
//import com.yihu.wlyy.entity.doctor.profile.Doctor;
//import com.yihu.wlyy.entity.education.HealthEduArticleOpHistory;
//import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
//import com.yihu.wlyy.entity.patient.SignFamily;
//import com.yihu.wlyy.repository.doctor.DoctorDao;
//import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
//import com.yihu.wlyy.repository.patient.SignFamilyDao;
//import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
//import com.yihu.wlyy.util.ElasticsearchUtil;
//import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.StringUtils;
//
//import java.util.*;
//
///**
// * Created by chenweida on 2017/8/31.
// */
//@Service
//public class GcEduArticleService {
//    @Autowired
//    private JdbcTemplate jdbcTemplate;
//    @Autowired
//    private SignFamilyDao signFamilyDao;
//    @Autowired
//    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
//    @Autowired
//    private HealthEduArticlePatientDao healthEduArticlePatientDao;
//    @Autowired
//    private DoctorDao doctorDao;
//
//    @Autowired
//    private ElastricSearchSave elastricSearchSave;
//
//    @Value("${es.type.HealthEduArticlePatient}")
//    private String esType;
//    @Value("${es.index.HealthEduArticlePatient}")
//    private String esIndex;
//
//    @Autowired
//    private ElasticsearchUtil elasticsearchUtil;
//
//    /**
//     * 初始化需要发送的患者
//     *
//     * @param patientSet
//     * @param patients
//     * @param labelType
//     * @param labelCode
//     * @param teamId
//     */
//    public void initPatient(Set<String> patientSet, String[] patients, String[] unPatients, String labelType, String labelCode, Long teamId) {
//        List params = new ArrayList();//sql参数
//        StringBuffer sb = new StringBuffer();//sql
//        //1 服务类型  2 健康情况 3 疾病类型 4 自定义标签
//        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
////            switch (labelType) {
////                case "1": {
////                    sb.append(" SELECT " +
////                            "  w.patient " +
////                            "FROM " +
////                            "  wlyy_sign_family w " +
////                            " WHERE " +
////                            "  w.`status` > 0 " +
////                            " AND w.code in ( select sign_code from  " +
////                            "  wlyy_sign_family_server where server_type=? ) ");
////                    params.add(labelCode);
////
////                    if (teamId != null && teamId > 0) {
////                        sb.append(" and w.admin_team_code=? ");
////                        params.add(teamId);
////                    }
////                    break;
////                }
////                case "2":
////                case "3":
////                case "4": {
////                    sb.append("SELECT w.patient FROM wlyy_sign_family w " +
////                            "WHERE " +
////                            "  w.patient in (SELECT  l.patient FROM  wlyy_sign_patient_label_info l WHERE l.label_type = ? AND l.label = ? and l.status=1) " +
////                            "AND w.`status` > 0");
////                    params.add(labelType);
////                    params.add(labelCode);
////                    if (teamId != null && teamId > 0) {
////                        sb.append(" and w.admin_team_code=? ");
////                        params.add(teamId);
////                    }
////                    break;
////                }
////            }
//
//            switch (labelType) {
//                case "1":{
//                    sb.append(" select w.patient FROM wlyy_sign_family w  left join wlyy_sign_family_server s on w.code=s.sign_code " +
//                            "where w.`status` > 0 and s.server_type=? ");
//                    params.add(labelCode);
//                }
//                case "2":
//                case "3":
//                case "4":{
//                    sb.append(" SELECT w.patient FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
//                            "where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
//                    params.add(labelType);
//                    params.add(labelCode);
//                    if (teamId != null && teamId > 0) {
//                        sb.append(" and w.admin_team_code=? ");
//                        params.add(teamId);
//                    }
//                    break;
//                }
//            }
//            List<String> groupPatient = jdbcTemplate.queryForList(sb.toString(), String.class, params.toArray());
//            patientSet.addAll(groupPatient);
//        }
//        if (patients != null && patients.length > 0) {
//            List<String> arrPatient = java.util.Arrays.asList(patients);
//            patientSet.addAll(arrPatient);
//        }
//        if (unPatients != null && unPatients.length > 0) {
//            for (String unPatient : unPatients) {
//                if (patientSet.contains(unPatient)) {
//                    patientSet.remove(unPatient);
//                }
//            }
//        }
//    }
//
//    /**
//     * 保存发送信息
//     *
//     * @param patientSet   患者set集和
//     * @param sendCode     发送人code、
//     * @param sendName     发送人名称
//     * @param sendMessage  发送人携带的信息
//     * @param teamId       发送人所属团队
//     * @param articleId    文章列表
//     * @param articlePic   文件封面
//     * @param articleTitle 文章主题
//     */
//    @Transactional
//    public List<com.yihu.es.entity.HealthEduArticlePatient> getSaveArticle(Set<String> patientSet,
//                                                                        String sendCode,
//                                                                        String sendName,
//                                                                        Integer sendType,
//                                                                        String sendMessage,
//                                                                        Long teamId,
//                                                                        String articleId,
//                                                                        String articlePic,
//                                                                        String articleTitle,
//                                                                        String articleContent,
//                                                                        String articleType,
//                                                                        String level1Type,
//                                                                        String level2Type,
//                                                                        String level,
//                                                                        String articleUrl) {
//        List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
//
//        Doctor doctor = doctorDao.findByCode(sendCode);
//        String batchNo = UUID.randomUUID().toString();
//        Date createTime = new Date();
//        for (String patient : patientSet) {
//            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
//            if (signFamily == null) {
//                continue;
//            }
//            com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient = new com.yihu.es.entity.HealthEduArticlePatient();
//            healthEduArticlePatient.setSendCode(sendCode);
//            healthEduArticlePatient.setSendName(sendName);
//            healthEduArticlePatient.setSendType(sendType);
//            healthEduArticlePatient.setPatient(patient);
//            healthEduArticlePatient.setPatientName(signFamily.getName());
//            healthEduArticlePatient.setAdminTeamCode(teamId);
//            if (doctor != null) {
//                healthEduArticlePatient.setHospital(doctor.getHospital());
//                healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
//                healthEduArticlePatient.setTown(doctor.getTown());
//                healthEduArticlePatient.setTownName(doctor.getTownName());
//                healthEduArticlePatient.setSendLevel(doctor.getLevel()!=null?String.valueOf(doctor.getLevel()):"");
//                healthEduArticlePatient.setSendPic(doctor.getPhoto());
//                healthEduArticlePatient.setSendSex(doctor.getSex()!=null?String.valueOf(doctor.getSex()):"");
//            }
//            healthEduArticlePatient.setBatchNo(batchNo);
//            healthEduArticlePatient.setCreateTime(createTime);
//
//            healthEduArticlePatient.setArticleId(articleId);
//            healthEduArticlePatient.setAttachedTitle(articleTitle);
//            healthEduArticlePatient.setAttachedPic(articlePic);
//            healthEduArticlePatient.setAttachedContent(articleContent);
//            healthEduArticlePatient.setAttachedMessage(sendMessage);
//            healthEduArticlePatient.setArticleType(articleType);
//            healthEduArticlePatient.setLevel(level);
//            healthEduArticlePatient.setLevel1Type(level1Type);
//            healthEduArticlePatient.setLevel2Type(level2Type);
//            healthEduArticlePatient.setType("1");//文章
//            healthEduArticlePatient.setArticleUrl(articleUrl);
//            healthEduArticlePatients.add(healthEduArticlePatient);
//
//        }
//        //保存到ES中
//        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
//        return healthEduArticlePatients;
//    }
//
//    public List<HealthEduArticlePatientModel> getPatientHealthLogs(String sendCode, String articleType, String level1Type, String level2Type, String level, String attachedTitle, String startTime, String endTime, int page, int pagesize) {
//        pagesize = page * pagesize;
//        page = (page - 1) * pagesize;
//
//        StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from health_edu_article_patient_test  " +
//                " where  sendCode='" + sendCode + "' ");
//        if (!StringUtils.isEmpty(articleType)) {
//            sql.append(" and  articleType='" + articleType + "'  ");
//        }
//        if (!StringUtils.isEmpty(attachedTitle)) {
//            sql.append(" and  attachedTitle like '%" + attachedTitle + "%'  ");
//        }
//        if (!StringUtils.isEmpty(level1Type)) {
//            sql.append(" and  level1Type='" + level1Type + "'  ");
//        }
//        if (!StringUtils.isEmpty(level2Type)) {
//            sql.append(" and  level2Type='" + level2Type + "'  ");
//        }
//        if (!StringUtils.isEmpty(level)) {
//            sql.append(" and  level='" + level + "'  ");
//        }
//        if (!StringUtils.isEmpty(startTime)) {
//
//            sql.append(" and  createTime>='" + changeDate(startTime) + "'  ");
//        }
//        if (!StringUtils.isEmpty(endTime)) {
//            sql.append(" and  createTime<='" + changeDate(endTime) + "'  ");
//        }
//        sql.append(" group by articleId order by createTime limit " + page + "," + pagesize);
//        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
//        List<HealthEduArticlePatientModel> returnList = new ArrayList<>();
//        esList.stream().forEach(one -> {
//            com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
//            if (p != null) {
//                p.setAllCount(one.getAllCount());
//                HealthEduArticlePatientModel heapm = new HealthEduArticlePatientModel();
//                BeanUtils.copyProperties(p, heapm);
//                returnList.add(heapm);
//            }
//        });
//        return returnList;
//    }
//
//    private com.yihu.es.entity.HealthEduArticlePatient findOne(String articleId) {
//        String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from health_edu_article_patient_test where articleId='" + articleId + "' order by createTime desc limit 0,1";
//        com.yihu.es.entity.HealthEduArticlePatient esList = (com.yihu.es.entity.HealthEduArticlePatient) elasticsearchUtil.excuteOneObject(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
//        return esList;
//    }
//
//    public Long getPatientHealthLogsCount(String sendCode, String articleType, String level1Type, String level2Type, String level, String attachedTitle, String startTime, String endTime) {
//        StringBuffer sql = new StringBuffer("select count(distinct articleId) count from health_edu_article_patient_test  " +
//                " where  sendCode='" + sendCode + "' ");
//        if (!StringUtils.isEmpty(articleType)) {
//            sql.append(" and  articleType='" + articleType + "'  ");
//        }
//        if (!StringUtils.isEmpty(attachedTitle)) {
//            sql.append(" and  attachedTitle like '%" + attachedTitle + "%'  ");
//        }
//        if (!StringUtils.isEmpty(level1Type)) {
//            sql.append(" and  level1Type='" + level1Type + "'  ");
//        }
//        if (!StringUtils.isEmpty(level2Type)) {
//            sql.append(" and  level2Type='" + level2Type + "'  ");
//        }
//        if (!StringUtils.isEmpty(level)) {
//            sql.append(" and  level='" + level + "'  ");
//        }
//        if (!StringUtils.isEmpty(startTime)) {
//
//            sql.append(" and  createTime>='" + changeDate(startTime) + "'  ");
//        }
//        if (!StringUtils.isEmpty(endTime)) {
//            sql.append(" and  createTime<='" + changeDate(endTime) + "'  ");
//        }
//        sql.append(" group by articleId ");
//        return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
//    }
//
//    private String changeDate(String quotaDate) {
//        return quotaDate + "T00:00:00+0800";
//    }
//
//    public void initPatient(Set<String> patientSet,String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth){
//
//        String tableSql = " select w.patient from wlyy_sign_family w ";
//        String whereSql = " where w.status>0  ";
//
//        if(!StringUtils.isEmpty(labelServe)){
//            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
//            whereSql += " and s.server_type in ("+labelServe+" ) ";
//        }
//        if(!StringUtils.isEmpty(labelHealth)||!StringUtils.isEmpty(labelDisease)){
//            tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
//            whereSql += " and l.status=1 ";
//            whereSql += " and ( ";
//        }
//        if(!StringUtils.isEmpty(labelHealth)){
//            whereSql += " (l.label_type = 2 AND l.label in ("+labelHealth+")) ";
//        }
//        if(!StringUtils.isEmpty(labelDisease)){
//            if(!whereSql.endsWith(" and ( ")) {
//                whereSql += " or (l.label_type = 3 AND l.label in ("+labelDisease+"))) ";
//            }else{
//                whereSql += " (l.label_type = 1 AND l.label in ("+labelDisease+"))) ";
//            }
//        }
//        if(!StringUtils.isEmpty(labelSex)){
//            tableSql += " left join wlyy_patient p on p.code=w.patient ";
//            whereSql += " and p.sex in ("+labelSex+") ";
//        }
//        if(!StringUtils.isEmpty(labelUnit)){
//            whereSql += " and w.hospital in ("+labelUnit+") ";
//        }
//        List<String> groupPatient = jdbcTemplate.queryForList(tableSql+whereSql, String.class);
//        patientSet.addAll(groupPatient);
//    }
//}
package com.yihu.wlyy.web.third.gateway.service;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.education.HealthEduArticlePatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.health.HealthEduArticleOpHistoryService;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.third.gateway.vo.HealthEduArticlePatientModel;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * Created by chenweida on 2017/8/31.
 */
@Service
public class GcEduArticleService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
    @Autowired
    private HealthEduArticlePatientDao healthEduArticlePatientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private ElastricSearchSave elastricSearchSave;
    @Value("${es.type.HealthEduArticlePatient}")
    private String esType;
    @Value("${es.index.HealthEduArticlePatient}")
    private String esIndex;
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    /**
     * 初始化需要发送的患者
     *
     * @param patientSet
     * @param patients
     * @param labelType
     * @param labelCode
     * @param teamId
     */
    public void initPatient(Set<String> patientSet, String[] patients, String[] unPatients, String labelType, String labelCode, Long teamId) {
        List params = new ArrayList();//sql参数
        StringBuffer sb = new StringBuffer();//sql
        //1 服务类型  2 健康情况 3 疾病类型 4 自定义标签
        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
            switch (labelType) {
                case "1":{
                    sb.append(" select w.patient FROM wlyy_sign_family w  left join wlyy_sign_family_server s on w.code=s.sign_code " +
                            "where w.`status` > 0 and s.server_type=? ");
                    params.add(labelCode);
                }
                case "2":
                case "3":
                case "4":{
                    sb.append(" SELECT w.patient FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
                            "where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
                    params.add(labelType);
                    params.add(labelCode);
                    if (teamId != null && teamId > 0) {
                        sb.append(" and w.admin_team_code=? ");
                        params.add(teamId);
                    }
                    break;
                }
            }
            List<String> groupPatient = jdbcTemplate.queryForList(sb.toString(), String.class, params.toArray());
            patientSet.addAll(groupPatient);
        }
        if (patients != null && patients.length > 0) {
            List<String> arrPatient = java.util.Arrays.asList(patients);
            patientSet.addAll(arrPatient);
        }
        if (unPatients != null && unPatients.length > 0) {
            for (String unPatient : unPatients) {
                if (patientSet.contains(unPatient)) {
                    patientSet.remove(unPatient);
                }
            }
        }
    }
    /**
     * 保存发送信息
     *
     * @param patientSet   患者set集和
     * @param sendCode     发送人code、
     * @param sendName     发送人名称
     * @param sendMessage  发送人携带的信息
     * @param teamId       发送人所属团队
     * @param articleId    文章列表
     * @param articlePic   文件封面
     * @param articleTitle 文章主题
     */
    @Transactional
    public List<com.yihu.es.entity.HealthEduArticlePatient> getSaveArticle(Set<String> patientSet,
                                                                        String sendCode,
                                                                        String sendName,
                                                                        Integer sendType,
                                                                        String sendMessage,
                                                                        Long teamId,
                                                                        String articleId,
                                                                        String articlePic,
                                                                        String articleTitle,
                                                                        String articleContent,
                                                                        String articleType,
                                                                        String level1Type,
                                                                        String level2Type,
                                                                        String level,
                                                                        String articleUrl) {
        List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
        Doctor doctor = doctorDao.findByCode(sendCode);
        String batchNo = UUID.randomUUID().toString();
        Date createTime = new Date();
        for (String patient : patientSet) {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patient);
            if (signFamily == null) {
                continue;
            }
            com.yihu.es.entity.HealthEduArticlePatient healthEduArticlePatient = new com.yihu.es.entity.HealthEduArticlePatient();
            healthEduArticlePatient.setSendCode(sendCode);
            healthEduArticlePatient.setSendName(sendName);
            healthEduArticlePatient.setSendType(sendType);
            healthEduArticlePatient.setPatient(patient);
            healthEduArticlePatient.setPatientName(signFamily.getName());
            healthEduArticlePatient.setAdminTeamCode(teamId);
            if (doctor != null) {
                healthEduArticlePatient.setHospital(doctor.getHospital());
                healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
                healthEduArticlePatient.setTown(doctor.getTown());
                healthEduArticlePatient.setTownName(doctor.getTownName());
                healthEduArticlePatient.setSendLevel(doctor.getLevel()!=null?String.valueOf(doctor.getLevel()):"");
                healthEduArticlePatient.setSendPic(doctor.getPhoto());
                healthEduArticlePatient.setSendSex(doctor.getSex()!=null?String.valueOf(doctor.getSex()):"");
            }
            healthEduArticlePatient.setBatchNo(batchNo);
            healthEduArticlePatient.setCreateTime(createTime);
            healthEduArticlePatient.setArticleId(articleId);
            healthEduArticlePatient.setAttachedTitle(articleTitle);
            healthEduArticlePatient.setAttachedPic(articlePic);
            healthEduArticlePatient.setAttachedContent(articleContent);
            healthEduArticlePatient.setAttachedMessage(sendMessage);
            healthEduArticlePatient.setArticleType(articleType);
            healthEduArticlePatient.setLevel(level);
            healthEduArticlePatient.setLevel1Type(level1Type);
            healthEduArticlePatient.setLevel2Type(level2Type);
            healthEduArticlePatient.setType("1");//文章
            healthEduArticlePatient.setArticleUrl(articleUrl);
            healthEduArticlePatients.add(healthEduArticlePatient);
        }
        //保存到ES中
        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        return healthEduArticlePatients;
    }
    public List<HealthEduArticlePatientModel> getPatientHealthLogs(String sendCode, String articleType, String level1Type, String level2Type, String level, String attachedTitle, String startTime, String endTime, int page, int pagesize) {
        pagesize = page * pagesize;
        page = (page - 1) * pagesize;
        StringBuffer sql = new StringBuffer("select *,count(articleId) allCount from health_edu_article_patient_test  " +
                " where  sendCode='" + sendCode + "' ");
        if (!StringUtils.isEmpty(articleType)) {
            sql.append(" and  articleType='" + articleType + "'  ");
        }
        if (!StringUtils.isEmpty(attachedTitle)) {
            sql.append(" and  attachedTitle like '%" + attachedTitle + "%'  ");
        }
        if (!StringUtils.isEmpty(level1Type)) {
            sql.append(" and  level1Type='" + level1Type + "'  ");
        }
        if (!StringUtils.isEmpty(level2Type)) {
            sql.append(" and  level2Type='" + level2Type + "'  ");
        }
        if (!StringUtils.isEmpty(level)) {
            sql.append(" and  level='" + level + "'  ");
        }
        if (!StringUtils.isEmpty(startTime)) {
            sql.append(" and  createTime>='" + changeDate(startTime) + "'  ");
        }
        if (!StringUtils.isEmpty(endTime)) {
            sql.append(" and  createTime<='" + changeDate(endTime) + "'  ");
        }
        sql.append(" group by articleId order by createTime limit " + page + "," + pagesize);
        List<com.yihu.es.entity.HealthEduArticlePatient> esList = elasticsearchUtil.excute(sql.toString(), com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        List<HealthEduArticlePatientModel> returnList = new ArrayList<>();
        esList.stream().forEach(one -> {
            com.yihu.es.entity.HealthEduArticlePatient p = findOne(one.getArticleId());
            if (p != null) {
                p.setAllCount(one.getAllCount());
                HealthEduArticlePatientModel heapm = new HealthEduArticlePatientModel();
                BeanUtils.copyProperties(p, heapm);
                returnList.add(heapm);
            }
        });
        return returnList;
    }
    private com.yihu.es.entity.HealthEduArticlePatient findOne(String articleId) {
        String sql = "select level,level2Type,level1Type,attachedContent,attachedTitle,articleId,createTime,articleType,sendCode,sendName from health_edu_article_patient_test where articleId='" + articleId + "' order by createTime desc limit 0,1";
        com.yihu.es.entity.HealthEduArticlePatient esList = (com.yihu.es.entity.HealthEduArticlePatient) elasticsearchUtil.excuteOneObject(sql, com.yihu.es.entity.HealthEduArticlePatient.class, esIndex, esType);
        return esList;
    }
    public Long getPatientHealthLogsCount(String sendCode, String articleType, String level1Type, String level2Type, String level, String attachedTitle, String startTime, String endTime) {
        StringBuffer sql = new StringBuffer("select count(distinct articleId) count from health_edu_article_patient_test  " +
                " where  sendCode='" + sendCode + "' ");
        if (!StringUtils.isEmpty(articleType)) {
            sql.append(" and  articleType='" + articleType + "'  ");
        }
        if (!StringUtils.isEmpty(attachedTitle)) {
            sql.append(" and  attachedTitle like '%" + attachedTitle + "%'  ");
        }
        if (!StringUtils.isEmpty(level1Type)) {
            sql.append(" and  level1Type='" + level1Type + "'  ");
        }
        if (!StringUtils.isEmpty(level2Type)) {
            sql.append(" and  level2Type='" + level2Type + "'  ");
        }
        if (!StringUtils.isEmpty(level)) {
            sql.append(" and  level='" + level + "'  ");
        }
        if (!StringUtils.isEmpty(startTime)) {
            sql.append(" and  createTime>='" + changeDate(startTime) + "'  ");
        }
        if (!StringUtils.isEmpty(endTime)) {
            sql.append(" and  createTime<='" + changeDate(endTime) + "'  ");
        }
        sql.append(" group by articleId ");
        return elasticsearchUtil.excuteForLong(sql.toString(), esIndex, esType);
    }
    private String changeDate(String quotaDate) {
        return quotaDate + "T00:00:00+0800";
    }
    public void initPatient(Set<String> patientSet,String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth){
        String tableSql = " select w.patient from wlyy_sign_family w ";
        String whereSql = " where w.status>0  ";
        if(!StringUtils.isEmpty(labelServe)){
            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
            whereSql += " and s.server_type in ("+labelServe+" ) ";
        }
        if(!StringUtils.isEmpty(labelHealth)||!StringUtils.isEmpty(labelDisease)){
            tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
            whereSql += " and l.status=1 ";
            whereSql += " and ( ";
        }
        if(!StringUtils.isEmpty(labelHealth)){
            whereSql += " (l.label_type = 2 AND l.label in ("+labelHealth+")) ";
        }
        if(!StringUtils.isEmpty(labelDisease)){
            if(!whereSql.endsWith(" and ( ")) {
                whereSql += " or (l.label_type = 3 AND l.label in ("+labelDisease+"))) ";
            }else{
                whereSql += " (l.label_type = 1 AND l.label in ("+labelDisease+"))) ";
            }
        }
        if(!StringUtils.isEmpty(labelSex)){
            tableSql += " left join wlyy_patient p on p.code=w.patient ";
            whereSql += " and p.sex in ("+labelSex+") ";
        }
        if(!StringUtils.isEmpty(labelUnit)){
            whereSql += " and w.hospital in ("+labelUnit+") ";
        }
        List<String> groupPatient = jdbcTemplate.queryForList(tableSql+whereSql, String.class);
        patientSet.addAll(groupPatient);
    }
}

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

@ -64,7 +64,7 @@ redis:
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
  show_sql: false
  ejb:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy