Преглед на файлове

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

zhanghaoyu преди 7 години
родител
ревизия
0b3cfa4bed
променени са 100 файла, в които са добавени 5642 реда и са изтрити 501 реда
  1. 100 0
      common/common-entity/src/main/java/com/yihu/es/entity/PatientRemindRecordESDO.java
  2. 9 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java
  3. 132 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyQuestionResult.java
  4. 39 2
      common/common-entity/src/main/java/com/yihu/wlyy/entity/imm/ChildImmuneVaccin.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  6. 27 17
      patient-co-manage/wlyy-manage/pom.xml
  7. 2 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/SpringSecurityConfig.java
  8. 105 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerQuestionnaireController.java
  9. 48 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerScreenResultController.java
  10. 304 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java
  11. 53 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/doctor/DoctorQuestionnaireController.java
  12. 105 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/doctor/DoctorSynergyManageController.java
  13. 9 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java
  14. 117 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionResult.java
  15. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyTemplateQuestion.java
  16. 97 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageCustomerOnlineRecordDO.java
  17. 196 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkordeReminderDO.java
  18. 96 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderCustomerLogDO.java
  19. 267 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderDO.java
  20. 76 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderExecutorDO.java
  21. 217 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderReserveConsultDO.java
  22. 217 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderServicerDO.java
  23. 148 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderServicerLogDO.java
  24. 6 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/filter/SessionOutTimeFilter.java
  25. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/SignFamilyDao.java
  26. 86 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/SignPatientLabelInfoDao.java
  27. 1 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/TownDao.java
  28. 13 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyQuestionResultDao.java
  29. 0 26
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionDao.java
  30. 29 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionsDao.java
  31. 10 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageCustomerOnlineRecordDao.java
  32. 9 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkOrderDao.java
  33. 17 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderCustomerLogDao.java
  34. 14 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderExecutorDao.java
  35. 16 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderReminderDao.java
  36. 26 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderServicerDao.java
  37. 17 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderServicerLogDao.java
  38. 9 10
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateQuestionService.java
  39. 4 4
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateService.java
  40. 176 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManageService.java
  41. 51 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/ScreenResultManageService.java
  42. 850 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
  43. 35 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyWorkorderServicerLogService.java
  44. 40 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java
  45. 39 12
      patient-co-manage/wlyy-manage/src/main/resources/application.yml
  46. 1 1
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_create_js.jsp
  47. 21 6
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/JMController.java
  48. 14 9
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/JMService.java
  49. 3 3
      patient-co-service/wlyy_service/src/main/resources/application.yml
  50. 2 2
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/WlyySignApplication.java
  51. 2 11
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/controller/FamilyLianqianController.java
  52. 2 3
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/FamilyDao.java
  53. 11 3
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/entity/FamilyLianQian.java
  54. 18 15
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/FamilyLianQianService.java
  55. 6 6
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/SignRenewZYService.java
  56. 3 2
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  57. 12 1
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentMysqlToEsQuotaJob.java
  58. 5 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java
  59. 10 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  60. 28 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/ChildImmuneVaccinJob.java
  61. 21 21
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/FollowUpSynJob.java
  62. 31 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java
  63. 167 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/imm/ChildVaccinImmuneService.java
  64. 56 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/ImmuneService.java
  65. 14 14
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  66. 1 0
      patient-co/patient-co-wlyy-job/src/main/resources/application-devtest.yml
  67. 14 14
      patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml
  68. 3 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  69. 43 0
      patient-co/patient-co-wlyy/doc/技术文档/es/可预约疫苗提醒日志新增索引
  70. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  71. 10 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyQuestionResultDao.java
  72. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplatesDao.java
  73. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildFamilyImmuneDao.java
  74. 20 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java
  75. 14 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  76. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  77. 5 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  78. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java
  79. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/CreditLogService.java
  80. 44 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  81. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  82. 23 22
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  83. 223 178
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java
  84. 415 22
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java
  85. 14 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java
  86. 23 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java
  87. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistScreenResultService.java
  88. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/rehabilitation/RehabilitationManageService.java
  89. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/rehabilitation/RehabilitationPlanService.java
  90. 155 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  91. 172 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java
  92. 18 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java
  93. 3 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/WeiXinCoreService.java
  94. 17 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  95. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  96. 23 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  97. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java
  98. 67 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java
  99. 53 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  100. 0 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java

+ 100 - 0
common/common-entity/src/main/java/com/yihu/es/entity/PatientRemindRecordESDO.java

@ -0,0 +1,100 @@
package com.yihu.es.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.searchbox.annotations.JestId;
import org.springframework.data.annotation.CreatedDate;
import java.util.Date;
/**
 * 疫苗提醒记录
 * @author zhangdan
 * @date 2018/09/27 20:51
 */
public class PatientRemindRecordESDO {
	
	@JestId
	private String id;
	// 业务主键
	private String code;
	private String patient;
	private String patientName;
	private String doctor;
	private String doctorName;
	private Integer remindType;//1计免提醒
	private Integer status;//0未发送 1已发送
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd'T'HHmmss.SSS'Z'")
	private Date createDate;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	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 getPatientName() {
		return patientName;
	}
	public void setPatientName(String patientName) {
		this.patientName = patientName;
	}
	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 Integer getRemindType() {
		return remindType;
	}
	public void setRemindType(Integer remindType) {
		this.remindType = remindType;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java

@ -36,6 +36,7 @@ public class CallRecord extends IdEntity {
    private String  doctorName; //签约医生姓名
    private Long  adminTeamCode; //团队id
    private Integer transferState;//转接状态1.成功 2.失败
    private String callLabel;//通话标签,多个逗号隔开。
    public String getCode() {
        return code;
@ -214,4 +215,12 @@ public class CallRecord extends IdEntity {
    public void setTransferState(Integer transferState) {
        this.transferState = transferState;
    }
    public String getCallLabel() {
        return callLabel;
    }
    public void setCallLabel(String callLabel) {
        this.callLabel = callLabel;
    }
}

+ 132 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyQuestionResult.java

@ -0,0 +1,132 @@
package com.yihu.wlyy.entity.doctor.survey;
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 humingfen on 2018/9/27.
 */
@Entity
@Table(name = "wlyy_survey_question_result")
public class SurveyQuestionResult extends IdEntity implements Serializable {
    //唯一标识
    private String code;
    //模板编码
    private String templateCode;
    //模板标题
    private  String templateTitle;
    //居民code
    private String patientCode;
    //居民名字
    private String patientName;
    //类型(1客服)
    private Integer type;
    //创建人(客服)code
    private String createUser;
    //创建人(客服)名称
    private String createUserName;
    //创建时间
    private Date createTime;
    public SurveyQuestionResult() {
    }
    public SurveyQuestionResult(String code, String templateCode, String templateTitle, String patientCode, String patientName, Integer type, String createUser, String createUserName, Date createTime) {
        this.code = code;
        this.templateCode = templateCode;
        this.templateTitle = templateTitle;
        this.patientCode = patientCode;
        this.patientName = patientName;
        this.type = type;
        this.createUser = createUser;
        this.createUserName = createUserName;
        this.createTime = createTime;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "template_code")
    public String getTemplateCode() {
        return templateCode;
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }
    @Column(name = "template_title")
    public String getTemplateTitle() {
        return templateTitle;
    }
    public void setTemplateTitle(String templateTitle) {
        this.templateTitle = templateTitle;
    }
    @Column(name = "patient_code")
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 39 - 2
common/common-entity/src/main/java/com/yihu/wlyy/entity/imm/ChildImmuneVaccin.java

@ -20,15 +20,19 @@ public class ChildImmuneVaccin extends IdEntity {
	private String idcard;                  //儿童身份证号
	private String ssc;                     //儿童社保卡号
	private String barcode;                 //儿童免疫条码
	private String childInfoCode;			  //child_info主键code
	private String ymkc;                    //true:可约,false:不可约
	private String ymmc;                    //疫苗名称
	private String ymkcsm;                  //疫苗库存说明(库存充足,可以预约/库存不足,不能预约)
	private String ymbm;                    //疫苗编码
	private String jzzc;                    //接种针次
	private Date jzrq;						  //接种日期
	private Integer isOut;					  //是否超过接种日期7天(0是 1不是)
	private Integer alert_tag;              //0待提醒,1已提醒
	private Date alert_time;                //提醒时间
	private Date create_time;               //创建时间
	private Date update_time;               //创建时间
	private Integer del;					  //0正常 1作废
	
	public String getCode() {
		return code;
@ -69,7 +73,15 @@ public class ChildImmuneVaccin extends IdEntity {
	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}
	
	public String getChildInfoCode() {
		return childInfoCode;
	}
	public void setChildInfoCode(String childInfoCode) {
		this.childInfoCode = childInfoCode;
	}
	public String getYmkc() {
		return ymkc;
	}
@ -109,7 +121,24 @@ public class ChildImmuneVaccin extends IdEntity {
	public void setJzzc(String jzzc) {
		this.jzzc = jzzc;
	}
	
	public Date getJzrq() {
		return jzrq;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public void setJzrq(Date jzrq) {
		this.jzrq = jzrq;
	}
	public Integer getIsOut() {
		return isOut;
	}
	public void setIsOut(Integer isOut) {
		this.isOut = isOut;
	}
	public Integer getAlert_tag() {
		return alert_tag;
	}
@ -143,4 +172,12 @@ public class ChildImmuneVaccin extends IdEntity {
	public void setAlert_time(Date alert_time) {
		this.alert_time = alert_time;
	}
	public Integer getDel() {
		return del;
	}
	public void setDel(Integer del) {
		this.del = del;
	}
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java

@ -30,7 +30,7 @@ public class Message extends IdEntity {
	/** type
	 *  消息类型(1.是家庭签约信息  2.体征消息  3分配健管师 4.随访提醒 5.咨询回复提醒,6.续方咨询待审核提醒,7.续方消息待取药
	 *  8.续方支付成功后团队长分配健管师,9线下调整完成,10意见反馈 11账号申诉,12.协同服务 13.孕检提醒 14.文章提交审核消息  15、健康文章审核结果
	 *  16.专科医生申请签约消息,17、家庭医生转诊预约消息,18、专科医生共管通知,19、
	 *  16.专科医生申请签约消息,17、家庭医生转诊预约消息,18、专科医生共管通知,:19 受理提醒,20 待办工作提醒 21 服务进展提醒-已完成 22 服务进展提醒-未完成 23 服务进展提醒-待完成 24 收到协同任务 25 在线助手已接收 26 在线助手已退回 27 协同服务已完成
	 *  101患者申请取消签约、102患者同意取消签约、103患者拒绝取消签约、104患者填写了血糖记录、105患者填写了血压记录、106患者填写了体重记录、
	 *  107患者填写了腰围记录、108患者填写了运动记录、109患者填写了用药记录、110患者填写了饮食记录、111患者提交了问卷随访、112请求添加好友消息、
	 *  113入群消息、114群解散消息、115踢出群消息、116新的网络咨询、117网络咨询追问、

+ 27 - 17
patient-co-manage/wlyy-manage/pom.xml

@ -32,10 +32,10 @@
                    <!--<groupId>org.springframework.boot</groupId>-->
                    <!--<artifactId>spring-boot-starter-logging</artifactId>-->
                <!--</exclusion>-->
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
                <!--<exclusion>-->
                    <!--<groupId>org.springframework.boot</groupId>-->
                    <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
                <!--</exclusion>-->
            </exclusions>
        </dependency>
        <!--<dependency>-->
@ -62,11 +62,11 @@
        </dependency>
        <!-- 使用intellij作为集成开发环境 本地测试时打开,要布署到正式线时要注释-->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>compile</scope>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>org.apache.tomcat.embed</groupId>-->
            <!--<artifactId>tomcat-embed-jasper</artifactId>-->
            <!--<scope>compile</scope>-->
        <!--</dependency>-->
        <!-- 以上 -->
        <dependency>
@ -204,18 +204,28 @@
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.4.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>classmate</artifactId>
                    <groupId>com.fasterxml</groupId>
                </exclusion>
            </exclusions>
            <version>2.7.0</version>
            <!--<exclusions>-->
                <!--<exclusion>-->
                    <!--<artifactId>classmate</artifactId>-->
                    <!--<groupId>com.fasterxml</groupId>-->
                <!--</exclusion>-->
            <!--</exclusions>-->
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.4.0</version>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-staticdocs</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>

+ 2 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/SpringSecurityConfig.java

@ -31,6 +31,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
                "/yueren/**",
                "/svr-iot/**",
                "/customer/**",
                "/synergy/**",
                "/third/**",
                "/admin/hos/doctor/importFromExcel",
                "/admin/hos/doctor/importData",
@ -72,7 +73,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
                .expressionHandler(webSecurityExpressionHandler())
                .antMatchers("/yueren/**").permitAll()
                .antMatchers("/svr-iot/device/**").permitAll()//物联网平台没有做登录(这里添加免登录验证)
//                .antMatchers("/admin/main").permitAll()
                .antMatchers("/synergy/**").permitAll() //i健康平台没有做登录(这里添加免登录验证)
//                .antMatchers("/login/**").permitAll()
//                .antMatchers("/admin/**").authenticated()
                .antMatchers("/admin/**").hasRole("USER")

+ 105 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerQuestionnaireController.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.controller.synergy.customer;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.synergy.QuestionnaireManageService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
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 Humingfen on 2018/9/29.
 */
@RestController
@RequestMapping(value = "/customer/question", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "客服端-调查问卷协同服务")
public class CustomerQuestionnaireController extends BaseController {
    @Autowired
    private QuestionnaireManageService questionnaireService;
    @Autowired
    private SynergyManageService synergyManageService;
    @RequestMapping(value = "saveAnswer", method = RequestMethod.POST)
    @ApiOperation(value = "保存用户答案")
    public String saveAnswer( @ApiParam(value = "问卷题目及选项", required = true)@RequestParam String jsonData,
                              @ApiParam(value = "客服code", required = true)@RequestParam(value = "customerCode")String customerCode,
                              @ApiParam(value = "居民code", required = true)@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "问卷标签", required = false)@RequestParam(value = "labelType")Integer labelType,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)", required = false, defaultValue = "1")@RequestParam(value = "source")Integer source,
                              @ApiParam(value = "协同工单服务对象表code", required = true)@RequestParam(value = "serviceCode")String serviceCode) {
        try {
            return  write(200, "保存成功!", "data", questionnaireService.saveResultAndAnswer(patientCode, labelType, customerCode, source,jsonData, serviceCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
    @RequestMapping(value = "getAnswers", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查统计结果")
    public String getAnswers(@ApiParam(value = "问卷code", required = true) @RequestParam String templateCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getAnswers(templateCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getResult", method = RequestMethod.GET)
    @ApiOperation(value = "查看客服对居民调查问卷结果")
    public String getResult(@ApiParam(value = "调查结果code") @RequestParam String questionResultCode) {
        try {
            return write(200, "查询成功!", "data", questionnaireService.getReuslt(questionResultCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "getQuestionnaireDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查看调查问卷内容")
    public String getQuestionnaireDetail(@ApiParam(value = "调查问卷code") @RequestParam String surveyCode) {
        try {
            com.alibaba.fastjson.JSONObject jsonObject = questionnaireService.getQuestionnaireDetail(surveyCode);
            return write(200, "查询成功!", "data", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
   /* @RequestMapping(value = "isNotException", method = RequestMethod.POST)
    @ApiOperation(value = "判断是否异常通话")
    public String isNotException(@ApiParam(value = "协同服务工单code") @RequestParam String workorderCode,
                                 @ApiParam(value = "客服code") @RequestParam String customerCode) {
        try {
            //判断是否有异常中断
            Integer count = synergyManageService.findExceptionCount(workorderCode, customerCode);
            return write(200, "查询成功!", "data", count > 0 ? true : false);
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "loadingInfo", method = RequestMethod.GET)
    @ApiOperation(value = "载入异常工单信息")
    public String loadingInfo(@ApiParam(value = "协同服务工单code") @RequestParam String workorderCode,
                                 @ApiParam(value = "客服code") @RequestParam String customerCode) {
        try {
            return write(200, "查询成功!", "data", synergyManageService.loadingInfo(workorderCode, customerCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "查询失败!");
        }
    }*/
}

+ 48 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerScreenResultController.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.controller.synergy.customer;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.synergy.ScreenResultManageService;
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 Humingfen on 2018/9/29.
 */
@RestController
@RequestMapping(value = "/customer/screen", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "客服端-疾病筛查协同服务")
public class CustomerScreenResultController extends BaseController {
    @Autowired
    private ScreenResultManageService screenResultService;
    @RequestMapping(value = "getScreenResultDetail", method = RequestMethod.GET)
    @ApiOperation(value = "获取筛查结果记录详情")
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
        try {
            return write(200, "获取成功!", "data", screenResultService.getScreenResultDetail(code));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getQuestions", method = RequestMethod.GET)
    @ApiOperation(value = "获取筛查问卷详情")
    public String getScreenDetail(@ApiParam(value = "筛查问卷code")@RequestParam(value = "code") String templateCode) {
        try {
            return write(200, "获取成功!", "data", screenResultService.getScreenDetail(templateCode));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
}

+ 304 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/customer/CustomerSynergyManageController.java

@ -0,0 +1,304 @@
package com.yihu.wlyy.controller.synergy.customer;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.call.CallRecord;
import com.yihu.wlyy.repository.call.CallRecordDao;
import com.yihu.wlyy.service.manager.user.UserService;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
@RestController
@RequestMapping(value = "/synergy/customer", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "集美客服系统")
public class CustomerSynergyManageController extends BaseController {
    public static final String CALL_LABEL="CALL_LABEL";
    @Autowired
    private SynergyManageService synergyManageService;
    @Autowired
    private UserService userService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private CallRecordDao callRecordDao;
    @RequestMapping(value = "/getWorkOrderInfo", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "获取协同服务工单信息")
    public String getWorkOrderInfo(@ApiParam(name="workorderCode",value="协同服务工单code")
                                @RequestParam(required = true)String workorderCode,
                                @ApiParam(name="patient",value="居民code")
                                @RequestParam(required = false)String patient,
                                @ApiParam(name="role",value="1医生,2客服管理员,3普通客服")
                                @RequestParam(required = true)Integer role){
        try {
            return write(200,"请求成功","data", synergyManageService.getWorkOrderInfo(workorderCode, patient, role));
        }catch (Exception e){
            error(e);
            return error(-1,"请求失败");
        }
    }
    @RequestMapping(value = "/dealWorkOrder",method = RequestMethod.POST)
    @ApiOperation(value = "处理协同服务")
    public String dealWorkOrder(@ApiParam(name="code",value="协同服务工单code")
                                    @RequestParam(required = true)String code,
                                @ApiParam(name="jsonData",value="接收负责人或者退回理由")
                                    @RequestParam(required = true)String jsonData,
                                @ApiParam(name="receiverCode",value="处理者code")
                                    @RequestParam(required = true)String receiverCode,
                                @ApiParam(name="status",value="2、接收,4、退回)")
                                    @RequestParam(required = true)Integer status){
        try {
            User user = userService.getUserByCode(receiverCode);
            synergyManageService.dealWorkOrder(code, user, jsonData, status);
            return write(200,"保存成功");
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "/labels", method = RequestMethod.GET)
    @ApiOperation("根据分组类型查找标签")
    public String labels(
            @ApiParam(name = "labelType", value = "1:服务类型(卫计委分组) 2:健康情况 3:疾病类型 4:团队标签(自定义标签)", required = true)
            @RequestParam(value = "labelType", required = true) String labelType) {
        try {
            return write(200,"保存成功", "data", synergyManageService.getLabels(labelType));
        } catch (Exception e) {
            error(e);
            return error(-1,"保存失败");
        }
    }
    @RequestMapping(value = "/unitLabels", method = RequestMethod.GET)
    @ApiOperation("获取所属社区")
    public String unitLabels(@ApiParam(name = "currentRoleCode", value = "选择的区县", required = false)
                             @RequestParam(value = "currentRoleCode", required = false) String currentRoleCode) {
        try {
            return write(200,"获取成功", "data", synergyManageService.getUnitLabels(currentRoleCode));
        } catch (Exception e) {
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "/towns", method = RequestMethod.GET)
    @ApiOperation("获取所属区县")
    public String towns() {
        try {
            return write(200,"获取成功", "data", synergyManageService.getTowns());
        } catch (Exception e) {
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "workorderList", method = RequestMethod.GET)
    @ApiOperation("客服系统-协同服务列表")
    public String workorderList(@ApiParam(name = "userCode", value = "客服code", required = false)
                                @RequestParam(value = "userCode", required = false)String userCode,
                                @ApiParam(name = "keywords", value = "输入医生姓名、姓名、社保卡、身份证号码", required = false)
                                @RequestParam(value = "keywords", required = false)String keywords,
                                @ApiParam(name = "workorderType", value = "服务类型(0、咨询,1、健康教育,2、预约,3、随访,4、问卷调查,5、疾病筛查)", required = false)
                                @RequestParam(value = "workorderType", required = false)Integer workorderType,
                                @ApiParam(name = "isMyTask", value = "是否由我负责,1、我负责,null全部", required = false)
                                @RequestParam(value = "isMyTask", required = false)Integer isMyTask,
                                @ApiParam(name = "status", value = "工单状态(0、草稿,1、未接受,2、处理中,3、处理完成,4、退回)", required = false)
                                @RequestParam(value = "status", required = false)Integer status,
                                @ApiParam(name = "priority", value = "工单优先级(0、普通,1、加急)", required = false)
                                @RequestParam(value = "priority", required = false)Integer priority,
                                @ApiParam(name = "timeout", value = "是否超时1、超时,null全部", required = false)
                                @RequestParam(value = "timeout", required = false)Integer timeout,
                                @ApiParam(name = "workorderCode", value = "服务编号", required = false)
                                @RequestParam(value = "workorderCode", required = false)String workorderCode,
                                @ApiParam(name = "principal", value = "负责人", required = false)
                                @RequestParam(value = "principal", required = false)String principal,
                                @ApiParam(name = "serviceStartTime", value = "服务开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceStartTime", required = false)String serviceStartTime,
                                @ApiParam(name = "serviceEndTime", value = "服务结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceEndTime", required = false)String serviceEndTime,
                                @ApiParam(name = "patientName", value = "服务对象名称", required = false)
                                @RequestParam(value = "patientName", required = false)String patientName,
                                @ApiParam(name = "ssc", value = "社保卡号", required = false)
                                @RequestParam(value = "ssc", required = false)String ssc,
                                @ApiParam(name = "idcard", value = "身份证号", required = false)
                                @RequestParam(value = "idcard", required = false)String idcard,
                                @ApiParam(name = "userType", value = "2、客服,3、客服管理员", required = true)
                                @RequestParam(value = "userType", required = true)Integer userType,
                                @ApiParam(name = "isAcceptTask", value = "1、我接收到的任务,2、我派发的任务,3、待接收(客服管理员),4、已接收(客服管理员)", required = true)
                                @RequestParam(value = "isAcceptTask", required = true)Integer isAcceptTask,
                                @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                @RequestParam(value = "page", required = true,defaultValue = "1")Integer page,
                                @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                                @RequestParam(value = "pageSize", required = true,defaultValue = "10")Integer pageSize){
        try {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            Map<String,Object> result = synergyManageService.workorderList(userCode,keywords,workorderType,isMyTask,status,priority,timeout,workorderCode,
                    principal,serviceStartTime,serviceEndTime,patientName,ssc,idcard,userType,isAcceptTask,page,pageSize);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/takeWorkorderNum", method = RequestMethod.GET)
    @ApiOperation(value = "获取协同服务取号信息")
    public String takeWorkorderNum(@ApiParam(name="workorderCode",value="协同服务工单code",required = false)
                                @RequestParam(required = true)String workorderCode,
                                @ApiParam(name="townCode",value="所属区县",required = false)
                                @RequestParam(required = false)String townCode,
                                @ApiParam(name="hospitalCode",value="所属社区",required = false)
                                @RequestParam(required = false)String hospitalCode,
                                @ApiParam(name="diseaseCode",value="疾病类型",required = false)
                                @RequestParam(required = false)String diseaseCode,
                                @ApiParam(name="healthCode",value="健康情况",required = false)
                                @RequestParam(required = false)String healthCode,
                                @ApiParam(name="serveCode",value="服务类型",required = false)
                                @RequestParam(required = false)String serveCode,
                                @ApiParam(name="isFollow",value="是否待跟进(1是,0否)",required = false)
                                @RequestParam(required = false)Integer isFollow){
        try {
            Map<String,Object> resultMap = synergyManageService.takeWorkorderNum(workorderCode,townCode,hospitalCode,
                    diseaseCode,healthCode,serveCode,isFollow);
            return write(200,"取号成功","data", resultMap);
        }catch (Exception e){
            error(e);
            return error(-1,"取号失败");
        }
    }
    @RequestMapping(value = "/reminderList", method = RequestMethod.GET)
    @ApiOperation(value = "获取催单列表")
    public String reminderList(@ApiParam(name="userCode",value="客服code",required = false)
                               @RequestParam(required = false)String userCode,
                               @ApiParam(name="receiveType",value="客服角色(1、客服,2、客服负责人)",required = false)
                               @RequestParam(required = false)Integer receiveType,
                               @ApiParam(name="sortType",value="排序(1、升序,2、降序)",required = false,defaultValue = "1")
                               @RequestParam(required = false,defaultValue = "1")Integer sortType){
        try{
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            List<Map<String,Object>> resultList = synergyManageService.reminderList(userCode,receiveType,sortType);
            return write(200,"获取成功","data", resultList);
        }catch (Exception e){
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "/workorderRate", method = RequestMethod.GET)
    @ApiOperation(value = "任务进度")
    public String workorderRate(@ApiParam(name="userCode",value="客服code",required = false)
                                @RequestParam(required = false)String userCode,
                                @ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                                @RequestParam(required = true)String workorderCode){
        try{
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            Map<String,Object> resultMap = synergyManageService.workorderRate(workorderCode,userCode);
            return write(200,"获取成功","data", resultMap);
        }catch (Exception e){
            error(e);
            return error(-1,"获取失败");
        }
    }
    @RequestMapping(value = "getCallLabelList",method = RequestMethod.GET)
    @ApiOperation(value = "显示所有通话标签")
    public String getCallLabelList(){
        try{
            String sql ="SELECT `code`,`value`,sort FROM system_dict WHERE dict_name='"+CALL_LABEL+"'";
            return write(200,"查询成功!","data",jdbcTemplate.queryForList(sql));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "saveCallLabel",method = RequestMethod.POST)
    @ApiOperation(value = "保存所有通话标签")
    public String saveCallLabel(@ApiParam(name="callCode",value="通话记录code")@RequestParam(required = false)String callCode,
                                @ApiParam(name="callLabels",value="通话标签,多个用逗号隔开")@RequestParam(required = false)String callLabels){
        try{
            String sql ="UPDATE manage_call_record SET call_label='"+callLabels+"' WHERE `code`='"+callCode+"'";
            jdbcTemplate.update(sql);
            return write(200,"保存成功!");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败!");
        }
    }
    @RequestMapping(value = "getCallInfo",method = RequestMethod.GET)
    @ApiOperation(value = "获取通话的详情")
    public String getCallTypeAndContent(@ApiParam(name="callCode",value="通话记录code")@RequestParam(required = false)String callCode){
        try{
            CallRecord callRecord = callRecordDao.findByCode(callCode);
            return write(200,"查询成功!","data",callCode);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "saveCallInfo",method = RequestMethod.POST)
    @ApiOperation(value = "显示所有通话标签")
    public String saveCallInfo(@ApiParam(name="callCode",value="通话记录code")@RequestParam(required = false)String callCode,
                                @ApiParam(name="serviceType",value="服务类型,多个用逗号隔开")@RequestParam(required = false)String serviceType,
                               @ApiParam(name="serviceContent",value="服务记录")@RequestParam(required = false)String serviceContent){
        try{
            String sql ="UPDATE manage_call_record SET service_type='"+serviceType+"',service_content='"+serviceContent+"' WHERE `code`='"+callCode+"'";
            jdbcTemplate.update(sql);
            return write(200,"保存成功!");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败!");
        }
    }
    @RequestMapping(value = "/taskSubmit", method = RequestMethod.POST)
    @ApiOperation(value = "协同任务提交")
    public String taskSubmit(@ApiParam(name="workorderCode",value="协同服务工单code",required = true)
                             @RequestParam(required = true)String workorderCode,
                             @ApiParam(name="dealResultRemark",value="说明",required = true)
                             @RequestParam(required = true)String dealResultRemark,
                             @ApiParam(name="dealResultAccessory",value="附件路径(多个用逗号隔开)",required = true)
                             @RequestParam(required = true)String dealResultAccessory){
        try{
            synergyManageService.taskSubmit(workorderCode,dealResultRemark,dealResultAccessory);
            return write(200,"提交成功");
        }catch (Exception e){
            error(e);
            return error(-1,"提交失败");
        }
    }
}

+ 53 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/doctor/DoctorQuestionnaireController.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.controller.synergy.doctor;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.service.synergy.QuestionnaireManageService;
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;
import java.text.SimpleDateFormat;
import java.util.List;
/**
 * 管理端问卷调查
 * Created by humingfen on 2018/9/27.
 */
@RestController
@RequestMapping(value = "/synergy/questionnaire", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-派发协同服务")
public class DoctorQuestionnaireController extends BaseController {
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    private QuestionnaireManageService questionnaireService;
    @RequestMapping(value = "/createWorkOrder", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "派发协同服务")
    public String addCallRecord(@ApiParam(name="jsonData",value="协同服务json字符串")
                                    @RequestParam(required = true)String jsonData,
                                @ApiParam(name="patientInfo",value="居民信息json字符串")
                                    @RequestParam(required = true)String patientInfo){
        try {
            ObjectMapper object = new ObjectMapper();
            object.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm"));
            ManageSynergyWorkorderDO manageSynergyWorkorderDO = object.readValue(jsonData, ManageSynergyWorkorderDO.class);
            List<ManageSynergyWorkorderServicerDO>  manageSynergyWorkorderServicerDOS = object.readValue(patientInfo, new TypeReference<List<ManageSynergyWorkorderServicerDO>>(){});
            return write(200,"保存成功","data",questionnaireService.createWorkOrder(manageSynergyWorkorderDO, manageSynergyWorkorderServicerDOS));
        }catch (Exception e){
            error(e);
            return error(-1,"保存失败");
        }
    }
}

+ 105 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/synergy/doctor/DoctorSynergyManageController.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.controller.synergy.doctor;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.service.synergy.SynergyManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
@Controller
@RequestMapping(value = "/synergy/doctor")
@Api(description = "医生端-协同服务")
public class DoctorSynergyManageController extends BaseController {
    @Autowired
    private SynergyManageService synergyManageService;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = "workorderList", method = RequestMethod.GET)
    @ApiOperation("医生端-协同服务列表")
    public String workorderList(@ApiParam(name = "userCode", value = "医生code", required = false)
                                @RequestParam(value = "userCode", required = false)String userCode,
                                @ApiParam(name = "workorderType", value = "服务类型(0、咨询,1、健康教育,2、预约,3、随访,4、问卷调查,5、疾病筛查)", required = false)
                                @RequestParam(value = "workorderType", required = false)Integer workorderType,
                                @ApiParam(name = "status", value = "工单状态(0、草稿,1、未接受,2、处理中,3、处理完成,4、退回)", required = false)
                                @RequestParam(value = "status", required = false)Integer status,
                                @ApiParam(name = "serviceStartTime", value = "服务开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceStartTime", required = false)String serviceStartTime,
                                @ApiParam(name = "serviceEndTime", value = "服务结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                @RequestParam(value = "serviceEndTime", required = false)String serviceEndTime,
                                @ApiParam(name = "isAcceptTask", value = "1、我接收到的任务,2、我派发的任务", required = true)
                                @RequestParam(value = "isAcceptTask", required = true)Integer isAcceptTask,
                                @ApiParam(name = "page", value = "第几页,从1开始", required = false)
                                @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
                                @ApiParam(name = "pageSize", value = "每页分页大小", required = false)
                                @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize){
        try {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            Map<String,Object> result = synergyManageService.workorderList(userCode,null,workorderType,null,status,null,null,null,
                    null,serviceStartTime,serviceEndTime,null,null,null,1,isAcceptTask,page,pageSize);
            return write(200, "获取成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "reminder", method = RequestMethod.POST)
    @ApiOperation("医生端-催单")
    public String reminder(@ApiParam(name = "userCode", value = "医生code", required = false)
                           @RequestParam(value = "userCode", required = false)String userCode,
                           @ApiParam(name = "workorderCode", value = "协同服务工单code", required = true)
                           @RequestParam(value = "workorderCode", required = true)String workorderCode){
        try {
            if(!StringUtils.isNotEmpty(userCode)){
                userCode = getUID();
            }
            synergyManageService.reminder(workorderCode,userCode,1);
            return write(200, "请求成功");
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "createWorkorder", method = RequestMethod.GET)
    @ApiOperation("医生端-创建协同服务")
    public String workorderList(@ApiParam(name = "workorder", value = "工单对象", required = false)
                                @RequestParam(value = "workorder")String workorder,
                                @ApiParam(name = "servicers", value = "服务对象", required = false)
                                @RequestParam(value = "servicers")String servicers){
        try {
            ManageSynergyWorkorderDO workorderDO = objectMapper.readValue(workorder,ManageSynergyWorkorderDO.class);
            JSONArray jsonArray = JSONArray.parseArray(servicers);
            List<ManageSynergyWorkorderServicerDO> servicerDOS = new ArrayList<>();
            for (int i=0;i<jsonArray.size();i++){
                ManageSynergyWorkorderServicerDO servicerDO = objectMapper.readValue(jsonArray.getJSONObject(i).toJSONString(),ManageSynergyWorkorderServicerDO.class);
                servicerDOS.add(servicerDO);
            }
            synergyManageService.createWorkorder(workorderDO,servicerDOS);
            return write(200, "获取成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 9 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/call/CallRecord.java

@ -36,6 +36,7 @@ public class CallRecord extends IdEntity {
    private String  doctorName; //签约医生姓名
    private Long  adminTeamCode; //团队id
    private Integer transferState;//转接状态1.成功 2.失败
    private String callLabel;//通话标签,多个逗号隔开。
    public String getCode() {
        return code;
@ -214,4 +215,12 @@ public class CallRecord extends IdEntity {
    public void setTransferState(Integer transferState) {
        this.transferState = transferState;
    }
    public String getCallLabel() {
        return callLabel;
    }
    public void setCallLabel(String callLabel) {
        this.callLabel = callLabel;
    }
}

+ 117 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyQuestionResult.java

@ -0,0 +1,117 @@
package com.yihu.wlyy.entity.survey;
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 humingfen on 2018/9/27.
 */
@Entity
@Table(name = "wlyy_survey_question_result")
public class SurveyQuestionResult extends IdEntity implements Serializable {
    //唯一标识
    private String code;
    //模板编码
    private String templateCode;
    //模板标题
    private  String templateTitle;
    //居民code
    private String patientCode;
    //居民名字
    private String patientName;
    //类型(1客服)
    private Integer type;
    //创建人(客服)code
    private String createUser;
    //创建人(客服)名称
    private String createUserName;
    //创建时间
    private Date createTime;
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "template_code")
    public String getTemplateCode() {
        return templateCode;
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }
    @Column(name = "template_title")
    public String getTemplateTitle() {
        return templateTitle;
    }
    public void setTemplateTitle(String templateTitle) {
        this.templateTitle = templateTitle;
    }
    @Column(name = "patient_code")
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/survey/SurveyTemplateQuestion.java

@ -14,7 +14,7 @@ import java.util.Date;
 */
@Entity
@Table(name = "wlyy_survey_template_questions")
public class SurveyTemplateQuestion extends IdEntity{
public class SurveyTemplateQuestions extends IdEntity{
    private static final long serialVersionUID = 1L;
    private String code;
    private String templateCode;//模板code

+ 97 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageCustomerOnlineRecordDO.java

@ -0,0 +1,97 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/9/27.
 * 客服在线记录表
 */
@Entity
@Table(name = "manage_customer_online_record")
public class ManageCustomerOnlineRecordDO extends IdEntity {
    private String code;
    private String customerCode;//客服code
    private String customerName;//客服名称
    private Integer status;//状态(1、在线,2、离线)
    private Date createTime;//创建时间
    private String jobNo;//客服工号
    private String seat;//席位
    private String phone;//客服电话
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "customer_code")
    public String getCustomerCode() {
        return customerCode;
    }
    public void setCustomerCode(String customerCode) {
        this.customerCode = customerCode;
    }
    @Column(name = "customer_name")
    public String getCustomerName() {
        return customerName;
    }
    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "job_no")
    public String getJobNo() {
        return jobNo;
    }
    public void setJobNo(String jobNo) {
        this.jobNo = jobNo;
    }
    @Column(name = "seat")
    public String getSeat() {
        return seat;
    }
    public void setSeat(String seat) {
        this.seat = seat;
    }
    @Column(name = "phone")
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
}

+ 196 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkordeReminderDO.java

@ -0,0 +1,196 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/10/8.
 * 催单记录表
 */
@Entity
@Table(name = "manage_synergy_workorder_reminder")
public class ManageSynergyWorkordeReminderDO extends IdEntity {
    private String code;
    private String workorderCode;//协同服务工单code
    private String createUser;//创建人code
    private String createUserName;//创建者姓名
    private Integer createUserType;//创建人类型(1、医生,2、客服,3、客服负责人)
    private String hospital;//创建人所属机构code
    private String hospitalName;//创建人所属机构的名称
    private Date createTime;//催单时间
    private String principalCode;//负责人code
    private String principalName;//负责人姓名
    private Integer workorderType;//服务类型(0、咨询,1、健康教育,2、预约,3、随访,4、问卷调查,5、疾病筛查)
    private String relationCode;//根据workorder_type关联业务code
    private String relationCodeName;//关联业务名称
    private Date serviceTime;//服务时间
    private String servicerKey;//服务对象其中五个人
    private String workorderRemark;//备注
    private Integer dealWith;//0、未处理,1、已处理
    private Integer priority;//工单优先级(0、普通,1、加急)
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "workorder_code")
    public String getWorkorderCode() {
        return workorderCode;
    }
    public void setWorkorderCode(String workorderCode) {
        this.workorderCode = workorderCode;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "create_user_type")
    public Integer getCreateUserType() {
        return createUserType;
    }
    public void setCreateUserType(Integer createUserType) {
        this.createUserType = createUserType;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "principal_code")
    public String getPrincipalCode() {
        return principalCode;
    }
    public void setPrincipalCode(String principalCode) {
        this.principalCode = principalCode;
    }
    @Column(name = "principal_name")
    public String getPrincipalName() {
        return principalName;
    }
    public void setPrincipalName(String principalName) {
        this.principalName = principalName;
    }
    @Column(name = "workorder_type")
    public Integer getWorkorderType() {
        return workorderType;
    }
    public void setWorkorderType(Integer workorderType) {
        this.workorderType = workorderType;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    @Column(name = "relation_code_name")
    public String getRelationCodeName() {
        return relationCodeName;
    }
    public void setRelationCodeName(String relationCodeName) {
        this.relationCodeName = relationCodeName;
    }
    @Column(name = "service_time")
    public Date getServiceTime() {
        return serviceTime;
    }
    public void setServiceTime(Date serviceTime) {
        this.serviceTime = serviceTime;
    }
    @Column(name = "servicer_key")
    public String getServicerKey() {
        return servicerKey;
    }
    public void setServicerKey(String servicerKey) {
        this.servicerKey = servicerKey;
    }
    @Column(name = "workorder_remark")
    public String getWorkorderRemark() {
        return workorderRemark;
    }
    public void setWorkorderRemark(String workorderRemark) {
        this.workorderRemark = workorderRemark;
    }
    @Column(name = "deal_with")
    public Integer getDealWith() {
        return dealWith;
    }
    public void setDealWith(Integer dealWith) {
        this.dealWith = dealWith;
    }
    @Column(name = "priority")
    public Integer getPriority() {
        return priority;
    }
    public void setPriority(Integer priority) {
        this.priority = priority;
    }
}

+ 96 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderCustomerLogDO.java

@ -0,0 +1,96 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/9/29.
 * 客服操作工单日志
 */
@Entity
@Table(name = "manage_synergy_workorder_customer_log")
public class ManageSynergyWorkorderCustomerLogDO extends IdEntity {
    private String code;
    private Date createTime;//添加时间
    private String workorderCode;//系统服务工单code
    private String servicePatientCode;//协同服务对象code
    private String createUserCode;//创建人(客服)code
    private String createUserName;//创建人(客服)名称
    private String callCode;//通话记录code
    private Integer status;//状态(0、未完成,1、处理完成)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "workorder_code")
    public String getWorkorderCode() {
        return workorderCode;
    }
    public void setWorkorderCode(String workorderCode) {
        this.workorderCode = workorderCode;
    }
    @Column(name = "service_patient_code")
    public String getServicePatientCode() {
        return servicePatientCode;
    }
    public void setServicePatientCode(String servicePatientCode) {
        this.servicePatientCode = servicePatientCode;
    }
    @Column(name = "create_user_code")
    public String getCreateUserCode() {
        return createUserCode;
    }
    public void setCreateUserCode(String createUserCode) {
        this.createUserCode = createUserCode;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "call_code")
    public String getCallCode() {
        return callCode;
    }
    public void setCallCode(String callCode) {
        this.callCode = callCode;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 267 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderDO.java

@ -0,0 +1,267 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/9/27.
 * 协同服务工单表
 */
@Entity
@Table(name = "manage_synergy_workorder")
public class ManageSynergyWorkorderDO extends IdEntity {
    private String code;//服务编号
    private Integer type;//服务类型(0、咨询,1、健康教育,2、预约,3、随访,4、问卷调查,5、疾病筛查)
    private Date serviceTime;//服务时间
    private Integer status;//工单状态(0、草稿,1、未接受,2、处理中,3、处理完成,4、退回)
    private Integer priority;//工单优先级(0、普通,1、加急)
    private Date createTime;//创建时间
    private String createUser;//创建人code
    private String createUserName;//创建人名称
    private String remark;//备注
    private Integer createUserType;//创建人类型(1、医生,2、客服)
    private Integer del;//逻辑删除(0、有效,1、删除)
    private String content;//服务内容
    private String relationCode;//根据type关联业务code
    private String relationCodeName;//关联业务名称
    private String returnedRemark;//退回操作备注说明
    private String dealResultRemark;//处理结果
    private String dealResultAccessory;//处理结果附件
    private Integer servicerCount;//服务对象人数
    private String servicerKey;//服务对象其中五个人
    private String receiverCode;//接收人code
    private String receiverName;//接收人名称
    private Integer receiverType;//接收人类型(1、医生,2、客服)
    private String hospital;//创建人所属机构code;
    private String hospitalName;//创建人所属机构名称
    private Date receiverTime;//工单(客服管理员)接收时间
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "service_time")
    public Date getServiceTime() {
        return serviceTime;
    }
    public void setServiceTime(Date serviceTime) {
        this.serviceTime = serviceTime;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "priority")
    public Integer getPriority() {
        return priority;
    }
    public void setPriority(Integer priority) {
        this.priority = priority;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "create_user_type")
    public Integer getCreateUserType() {
        return createUserType;
    }
    public void setCreateUserType(Integer createUserType) {
        this.createUserType = createUserType;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    @Column(name = "relation_code_name")
    public String getRelationCodeName() {
        return relationCodeName;
    }
    public void setRelationCodeName(String relationCodeName) {
        this.relationCodeName = relationCodeName;
    }
    @Column(name = "returned_remark")
    public String getReturnedRemark() {
        return returnedRemark;
    }
    public void setReturnedRemark(String returnedRemark) {
        this.returnedRemark = returnedRemark;
    }
    @Column(name = "deal_result_remark")
    public String getDealResultRemark() {
        return dealResultRemark;
    }
    public void setDealResultRemark(String dealResultRemark) {
        this.dealResultRemark = dealResultRemark;
    }
    @Column(name = "deal_result_accessory")
    public String getDealResultAccessory() {
        return dealResultAccessory;
    }
    public void setDealResultAccessory(String dealResultAccessory) {
        this.dealResultAccessory = dealResultAccessory;
    }
    @Column(name = "servicer_count")
    public Integer getServicerCount() {
        return servicerCount;
    }
    public void setServicerCount(Integer servicerCount) {
        this.servicerCount = servicerCount;
    }
    @Column(name = "servicer_key")
    public String getServicerKey() {
        return servicerKey;
    }
    public void setServicerKey(String servicerKey) {
        this.servicerKey = servicerKey;
    }
    @Column(name = "receiver_code")
    public String getReceiverCode() {
        return receiverCode;
    }
    public void setReceiverCode(String receiverCode) {
        this.receiverCode = receiverCode;
    }
    @Column(name = "receiver_type")
    public Integer getReceiverType() {
        return receiverType;
    }
    public void setReceiverType(Integer receiverType) {
        this.receiverType = receiverType;
    }
    @Column(name = "receiver_name")
    public String getReceiverName() {
        return receiverName;
    }
    public void setReceiverName(String receiverName) {
        this.receiverName = receiverName;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "receiver_time")
    public Date getReceiverTime() {
        return receiverTime;
    }
    public void setReceiverTime(Date receiverTime) {
        this.receiverTime = receiverTime;
    }
}

+ 76 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderExecutorDO.java

@ -0,0 +1,76 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by 刘文彬 on 2018/9/27.
 * 协同服务执行人表
 */
@Entity
@Table(name = "manage_synergy_workorder_executor")
public class ManageSynergyWorkorderExecutorDO extends IdEntity {
    private String code;
    private String workorderCode;//协同服务工单code
    private Integer executorType;//执行人类型(1、负责人(客服),2、协作着(客服),3、医生)
    private String executorCode;//执行者code
    private String executorName;//执行人名称
    private Integer del;//逻辑删除(0、有效,1、删除)
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "workorder_code")
    public String getWorkorderCode() {
        return workorderCode;
    }
    public void setWorkorderCode(String workorderCode) {
        this.workorderCode = workorderCode;
    }
    @Column(name = "executor_type")
    public Integer getExecutorType() {
        return executorType;
    }
    public void setExecutorType(Integer executorType) {
        this.executorType = executorType;
    }
    @Column(name = "executor_code")
    public String getExecutorCode() {
        return executorCode;
    }
    public void setExecutorCode(String executorCode) {
        this.executorCode = executorCode;
    }
    @Column(name = "executor_name")
    public String getExecutorName() {
        return executorName;
    }
    public void setExecutorName(String executorName) {
        this.executorName = executorName;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 217 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderReserveConsultDO.java

@ -0,0 +1,217 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/9/27.
 * 咨询、预约操作日志表
 */
@Entity
@Table(name = "manage_synergy_workorder_reserve_consult")
public class ManageSynergyWorkorderReserveConsultDO extends IdEntity {
    private String code;
    private Integer dealType;//处理方式:1.电话回复,2.客服回复
    private Date dealTime;//处理时间
    private Integer dealState;//处理结果:1.完成,2.无法联系居民
    private Integer dealContent;//处理内容
    private Integer dealReason;//处理取消原因:0.没有号源、1.病人取消
    private String orderHospital;//预约医院code
    private String orderHospitalName;//预约医院
    private String orderDept;//预约科室code
    private String orderDeptName;//预约科室名称
    private String orderDoctor;//预约医生code
    private String orderDoctorName;//预约医生名称
    private Date orderTime;//预约时间段
    private Date registerTime;//挂号时间
    private String user;//创建人(客服)code
    private String userName;//客服姓名(创建人)
    private Date createTime;//创建时间
    private String workorderCode;//协同服务工单code
    private String servicePatientCode;//协同服务对象code
    private String callCode;//通话记录code
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "deal_type")
    public Integer getDealType() {
        return dealType;
    }
    public void setDealType(Integer dealType) {
        this.dealType = dealType;
    }
    @Column(name = "deal_time")
    public Date getDealTime() {
        return dealTime;
    }
    public void setDealTime(Date dealTime) {
        this.dealTime = dealTime;
    }
    @Column(name = "deal_state")
    public Integer getDealState() {
        return dealState;
    }
    public void setDealState(Integer dealState) {
        this.dealState = dealState;
    }
    @Column(name = "deal_content")
    public Integer getDealContent() {
        return dealContent;
    }
    public void setDealContent(Integer dealContent) {
        this.dealContent = dealContent;
    }
    @Column(name = "deal_reason")
    public Integer getDealReason() {
        return dealReason;
    }
    public void setDealReason(Integer dealReason) {
        this.dealReason = dealReason;
    }
    @Column(name = "order_hospital")
    public String getOrderHospital() {
        return orderHospital;
    }
    public void setOrderHospital(String orderHospital) {
        this.orderHospital = orderHospital;
    }
    @Column(name = "order_hospital_name")
    public String getOrderHospitalName() {
        return orderHospitalName;
    }
    public void setOrderHospitalName(String orderHospitalName) {
        this.orderHospitalName = orderHospitalName;
    }
    @Column(name = "order_dept")
    public String getOrderDept() {
        return orderDept;
    }
    public void setOrderDept(String orderDept) {
        this.orderDept = orderDept;
    }
    @Column(name = "order_dept_name")
    public String getOrderDeptName() {
        return orderDeptName;
    }
    public void setOrderDeptName(String orderDeptName) {
        this.orderDeptName = orderDeptName;
    }
    @Column(name = "order_doctor")
    public String getOrderDoctor() {
        return orderDoctor;
    }
    public void setOrderDoctor(String orderDoctor) {
        this.orderDoctor = orderDoctor;
    }
    @Column(name = "order_doctor_name")
    public String getOrderDoctorName() {
        return orderDoctorName;
    }
    public void setOrderDoctorName(String orderDoctorName) {
        this.orderDoctorName = orderDoctorName;
    }
    @Column(name = "order_time")
    public Date getOrderTime() {
        return orderTime;
    }
    public void setOrderTime(Date orderTime) {
        this.orderTime = orderTime;
    }
    @Column(name = "register_time")
    public Date getRegisterTime() {
        return registerTime;
    }
    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    }
    @Column(name = "user")
    public String getUser() {
        return user;
    }
    public void setUser(String user) {
        this.user = user;
    }
    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "workorder_code")
    public String getWorkorderCode() {
        return workorderCode;
    }
    public void setWorkorderCode(String workorderCode) {
        this.workorderCode = workorderCode;
    }
    @Column(name = "service_patient_code")
    public String getServicePatientCode() {
        return servicePatientCode;
    }
    public void setServicePatientCode(String servicePatientCode) {
        this.servicePatientCode = servicePatientCode;
    }
    @Column(name = "call_code")
    public String getCallCode() {
        return callCode;
    }
    public void setCallCode(String callCode) {
        this.callCode = callCode;
    }
}

+ 217 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderServicerDO.java

@ -0,0 +1,217 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/9/27.
 * 协同服务工单的服务对象表
 */
@Entity
@Table(name = "manage_synergy_workorder_servicer")
public class ManageSynergyWorkorderServicerDO extends IdEntity {
    private String code;
    private Integer workorderType;//服务类型(0、咨询,1、健康教育,2、预约,3、随访,4、问卷调查,5、疾病筛查)
    private String workorderCode;//协同服务工单code
    private Integer status;//服务状态(1、待处理,2、处理中,3、处理完成)
    private Date completeTime;//完成时间
    private Date createTime;//创建时间
    private String servicePatientCode;//服务对象(居民)code
    private String servicePatientName;//服务对象(居民)名称
    private String executorCode;//服务执行完成人的code
    private String executorName;//服务执行完成人的名称
    private Integer executorType;//服务完成人类型(1、医生,2、客服)
    private String ssc;//服务对象(居民)社保卡号
    private String idcard;//服务对象(居民)身份证
    private String mobile;//服务对象(居民)联系号码
    private String hospital;//医院机构编码
    private String hospitalName;//机构名称
    private String town;//区县编码
    private String townName;//区县名称
    private String relationCode;//工单类型所关联的业务code
    private String relationCodeName;//关联业务名称
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "workorder_code")
    public String getWorkorderCode() {
        return workorderCode;
    }
    public void setWorkorderCode(String workorderCode) {
        this.workorderCode = workorderCode;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "complete_time")
    public Date getCompleteTime() {
        return completeTime;
    }
    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "service_patient_code")
    public String getServicePatientCode() {
        return servicePatientCode;
    }
    public void setServicePatientCode(String servicePatientCode) {
        this.servicePatientCode = servicePatientCode;
    }
    @Column(name = "service_patient_name")
    public String getServicePatientName() {
        return servicePatientName;
    }
    public void setServicePatientName(String servicePatientName) {
        this.servicePatientName = servicePatientName;
    }
    @Column(name = "executor_code")
    public String getExecutorCode() {
        return executorCode;
    }
    public void setExecutorCode(String executorCode) {
        this.executorCode = executorCode;
    }
    @Column(name = "executor_name")
    public String getExecutorName() {
        return executorName;
    }
    public void setExecutorName(String executorName) {
        this.executorName = executorName;
    }
    @Column(name = "executor_type")
    public Integer getExecutorType() {
        return executorType;
    }
    public void setExecutorType(Integer executorType) {
        this.executorType = executorType;
    }
    @Column(name = "ssc")
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    @Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "town")
    public String getTown() {
        return town;
    }
    public void setTown(String town) {
        this.town = town;
    }
    @Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    @Column(name = "workorder_type")
    public Integer getWorkorderType() {
        return workorderType;
    }
    public void setWorkorderType(Integer workorderType) {
        this.workorderType = workorderType;
    }
    @Column(name = "relation_code_name")
    public String getRelationCodeName() {
        return relationCodeName;
    }
    public void setRelationCodeName(String relationCodeName) {
        this.relationCodeName = relationCodeName;
    }
}

+ 148 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/synergy/ManageSynergyWorkorderServicerLogDO.java

@ -0,0 +1,148 @@
package com.yihu.wlyy.entity.synergy;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/9/27.
 * 协同服务处理操作日志
 */
@Entity
@Table(name = "manage_synergy_workorder_servicer_log")
public class ManageSynergyWorkorderServicerLogDO extends IdEntity {
    private String code;
    private Integer personal;//是否为本人(1、患者本人,2、患者家属)
    private Integer callStatus;//通话状态(1、正常通话,2、无人接听,3、拒接,4、占线,5、关机,6、停机,7、无法接通,8、空号错号)
    private Integer returnVisit;//回访(1、有效回访,2、无效回访)
    private Integer followUp;//是否跟进(1、无需跟进,2、待跟进)
    private Integer emphasis;//是否重点患者(1、重点患者,2、非重点患者)
    private String remark;//备注
    private Date createTime;//添加时间
    private String workorderCode;//系统服务工单code
    private String servicePatientCode;//协同服务对象code
    private String createUserCode;//创建人(客服)code
    private String createUserName;//创建人(客服)名称
    private String callCode;//通话记录code
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "personal")
    public Integer getPersonal() {
        return personal;
    }
    public void setPersonal(Integer personal) {
        this.personal = personal;
    }
    @Column(name = "call_status")
    public Integer getCallStatus() {
        return callStatus;
    }
    public void setCallStatus(Integer callStatus) {
        this.callStatus = callStatus;
    }
    @Column(name = "return_visit")
    public Integer getReturnVisit() {
        return returnVisit;
    }
    public void setReturnVisit(Integer returnVisit) {
        this.returnVisit = returnVisit;
    }
    @Column(name = "follow_up")
    public Integer getFollowUp() {
        return followUp;
    }
    public void setFollowUp(Integer followUp) {
        this.followUp = followUp;
    }
    @Column(name = "emphasis")
    public Integer getEmphasis() {
        return emphasis;
    }
    public void setEmphasis(Integer emphasis) {
        this.emphasis = emphasis;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "workorder_code")
    public String getWorkorderCode() {
        return workorderCode;
    }
    public void setWorkorderCode(String workorderCode) {
        this.workorderCode = workorderCode;
    }
    @Column(name = "service_patient_code")
    public String getServicePatientCode() {
        return servicePatientCode;
    }
    public void setServicePatientCode(String servicePatientCode) {
        this.servicePatientCode = servicePatientCode;
    }
    @Column(name = "create_user_code")
    public String getCreateUserCode() {
        return createUserCode;
    }
    public void setCreateUserCode(String createUserCode) {
        this.createUserCode = createUserCode;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "call_code")
    public String getCallCode() {
        return callCode;
    }
    public void setCallCode(String callCode) {
        this.callCode = callCode;
    }
}

+ 6 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/filter/SessionOutTimeFilter.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.filter;
import io.vavr.match.annotation.Patterns;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
@ -8,6 +10,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Pattern;
/**
 * @author lincl
@ -15,6 +18,7 @@ import java.io.IOException;
 * @created 2016/3/26
 */
@Component("loginFilter")
@Profile({ "prod"})
public class SessionOutTimeFilter extends OncePerRequestFilter {
    @Override
@ -27,7 +31,8 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
                || path.indexOf("/svr-iot") != -1
                || path.indexOf(httpServletRequest.getContextPath() + "/static") != -1
                || path.indexOf("swagger") != -1
                || path.indexOf(httpServletRequest.getContextPath() + "/v2/api-docs") != -1) {
                || path.indexOf(httpServletRequest.getContextPath() + "/v2/api-docs") != -1
                || path.indexOf("/synergy/doctor") != -1) {
            filterChain.doFilter(httpServletRequest, httpServletResponse);
            return;
        }

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

@ -34,7 +34,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.patient = ?1 and a.status >= 0")
    List<SignFamily> findAllSignByPatient(String patient);
    @Query("select a from SignFamily a where a.patient = ?1 and a.status > 0 and a.expensesStatus='1'")
    @Query("select a from SignFamily a where a.patient = ?1 and a.status =1 and a.expensesStatus='1'")
    SignFamily findSignByPatient(String patient);
    @Query("select a from SignFamily a where a.patient = ?1 and a.status > 0 and a.expensesStatus ='1' order by a.czrq desc")

+ 86 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/SignPatientLabelInfoDao.java

@ -0,0 +1,86 @@
package com.yihu.wlyy.repository;
import com.yihu.wlyy.entity.SignPatientLabelInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr on 2016/10/9.
 */
public interface SignPatientLabelInfoDao extends
        PagingAndSortingRepository<SignPatientLabelInfo, Long>,
        JpaSpecificationExecutor<SignPatientLabelInfo> {
    /**
     * 查询某个患者的标签
     *
     * @param patient 患者
     * @param status  状态
     * @return
     */
    List<SignPatientLabelInfo> findByPatientAndStatus(String patient, Integer status);
    /**
     * 查询某个患者的标签
     *
     * @param patient 患者
     * @param status  状态
     * @return
     */
    @Query("select f from SignPatientLabelInfo f,SignPatientLabel l where f.patient = ?1 and f.status = ?2 and f.label = l.labelCode and f.labelType =l.labelType" +
            " and l.status = ?2 and (l.labelType <> '4' or l.teamCode = ?3 or ( l.labelType = '4' and l.labelCode in (1,2)) )")
    List<SignPatientLabelInfo> findByPatientAndStatusByTeam(String patient, Integer status, Long teamCode);
    /**
     * 查询某个患者的某个类型标签
     *
     * @param patient   患者
     * @param labelType 标签类型
     * @param status    状态
     * @return
     */
    List<SignPatientLabelInfo> findByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
    /**
     * 查询某个患者的某个类型的某个标签
     *
     * @param patient   患者
     * @param labelCode  标签代码
     * @param labelType 标签类型
     * @param status    状态
     * @return
     */
    SignPatientLabelInfo findByPatientAndLabelAndLabelTypeAndStatus(String patient, String labelCode, String labelType, Integer status);
    /**
     * 删除患者的某个标签类型的所有指定状态标签
     *
     * @param patient
     * @param labelType
     * @param status
     * @return
     */
    @Modifying
    @Query("update SignPatientLabelInfo set status = 0 where patient = ?1 and labelType = ?2 and status = ?3")
    int deleteByPatientAndLabelTypeAndStatus(String patient, String labelType, Integer status);
    @Modifying
    @Query("update SignPatientLabelInfo set status = 0 where label = ?1 and status = 1")
    int deleteByLabel(String labelCode);
    /**
     * 更新某个标签名称
     *
     * @param labelName
     * @param labelCode
     * @return
     */
    @Modifying
    @Query("update SignPatientLabelInfo a set a.labelName = ?1 where a.label= ?2 and a.labelType = '4' ")
    int updateLabelName(String labelName, String labelCode);
}

+ 1 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/TownDao.java

@ -5,11 +5,10 @@
 *******************************************************************************/
package com.yihu.wlyy.repository;
import com.yihu.wlyy.entity.Town;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.Town;
public interface TownDao extends PagingAndSortingRepository<Town, Long> {
	// 根據CODE查詢區縣名稱
	@Query("select p from Town p where p.code = ?1")

+ 13 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyQuestionResultDao.java

@ -0,0 +1,13 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyQuestionResult;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by humingfen on 2018/9/27.
 */
public interface SurveyQuestionResultDao extends PagingAndSortingRepository<SurveyQuestionResult, Long>, JpaSpecificationExecutor<SurveyQuestionResult> {
    SurveyQuestionResult findByCode(String code);
}

+ 0 - 26
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionDao.java

@ -1,26 +0,0 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestion;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/3/7.
 */
public interface SurveyTemplateQuestionDao extends PagingAndSortingRepository<SurveyTemplateQuestion,Long>,JpaSpecificationExecutor<SurveyTemplateQuestion> {
    @Query("update SurveyTemplateQuestion set del = 0 where templateCode=?1 and del = 1")
    @Modifying
    void updateDelByTemplateCode(String templateCode);
    @Modifying
    void deleteByTemplateCode(String templateCode);
    List<SurveyTemplateQuestion> findByTemplateCodeAndDel(String templateCode,String del);
    SurveyTemplateQuestion findByCode(String code);
}

+ 29 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateQuestionsDao.java

@ -0,0 +1,29 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/3/7.
 */
public interface SurveyTemplateQuestionsDao extends PagingAndSortingRepository<SurveyTemplateQuestions,Long>,JpaSpecificationExecutor<SurveyTemplateQuestions> {
    @Query("update SurveyTemplateQuestions set del = 0 where templateCode=?1 and del = 1")
    @Modifying
    void updateDelByTemplateCode(String templateCode);
    @Modifying
    void deleteByTemplateCode(String templateCode);
    List<SurveyTemplateQuestions> findByTemplateCodeAndDel(String templateCode, String del);
    SurveyTemplateQuestions findByCode(String code);
    @Query("select q from SurveyTemplateQuestions q where q.templateCode = ?1")
    List<SurveyTemplateQuestions> findByTemplateCode(String templateCode);
}

+ 10 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageCustomerOnlineRecordDao.java

@ -0,0 +1,10 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageCustomerOnlineRecordDO;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
public interface ManageCustomerOnlineRecordDao extends PagingAndSortingRepository<ManageCustomerOnlineRecordDO, Long> {
}

+ 9 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkOrderDao.java

@ -0,0 +1,9 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface ManageSynergyWorkOrderDao extends PagingAndSortingRepository<ManageSynergyWorkorderDO, Long> {
    ManageSynergyWorkorderDO findByCode(String workorderCode);
}

+ 17 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderCustomerLogDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderCustomerLogDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by 刘文彬 on 2018/9/30.
 */
public interface ManageSynergyWorkorderCustomerLogDao extends PagingAndSortingRepository<ManageSynergyWorkorderCustomerLogDO, Long> {
    @Query("select count(distinct l.callCode) from ManageSynergyWorkorderCustomerLogDO l where l.servicePatientCode=?1 ")
    Integer callNumByWorkorder(String servicePatientCode);
    @Query("select count(1) from ManageSynergyWorkorderCustomerLogDO cl where cl.workorderCode = ?1 and cl.createUserCode = ?2 and cl.status = 0")
    Integer findExceptionCount(String workorderCode, String customerCode);
}

+ 14 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderExecutorDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderExecutorDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface ManageSynergyWorkorderExecutorDao extends PagingAndSortingRepository<ManageSynergyWorkorderExecutorDO, Long> {
    @Query("select e from ManageSynergyWorkorderExecutorDO e where e.workorderCode = ?1 and e.executorType = ?2 and e.del=1")
    List<ManageSynergyWorkorderExecutorDO> findByWorkorderCode(String workorderCode, Integer executorType);
}

+ 16 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderReminderDao.java

@ -0,0 +1,16 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkordeReminderDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderExecutorDO;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/10/8.
 */
public interface ManageSynergyWorkorderReminderDao extends PagingAndSortingRepository<ManageSynergyWorkordeReminderDO, Long> {
    List<ManageSynergyWorkordeReminderDO> findByPrincipalCodeAndDealWith(String principalCode,Integer dealWith);
}

+ 26 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderServicerDao.java

@ -0,0 +1,26 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
public interface ManageSynergyWorkorderServicerDao extends PagingAndSortingRepository<ManageSynergyWorkorderServicerDO, Long> {
    @Query(" select count(1) from ManageSynergyWorkorderServicerDO s where s.workorderCode=?1 and s.status=?2 ")
    Integer findByWorkorderCodeCount(String workorderCode,Integer status);
    @Modifying
    @Query("update ManageSynergyWorkorderServicerDO s set s.relationCode = ?2 where s.code = ?1")
    void updateRelationCodeByCode(String serviceCode, String questionResultCode);
    //根据工单code和居民code获取处理完成的服务对象信息
    @Query("select s from ManageSynergyWorkorderServicerDO s where s.workorderCode = ?1 and s.servicePatientCode = ?2 and s.status = 3")
    ManageSynergyWorkorderServicerDO findByWorkOrderCodeAndPatientCode(String workorderCode, String patient);
    @Query("select count(1) from ManageSynergyWorkorderServicerDO s where s.workorderCode=?1 and s.executorCode=?2 and s.status=?3")
    Integer countByWorkorderCodeAndExecutorCodeAndStatus(String workorderCode,String executorCode,Integer status);
    ManageSynergyWorkorderServicerDO findByCode(String code);
}

+ 17 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/synergy/ManageSynergyWorkorderServicerLogDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.synergy;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerLogDO;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by 刘文彬 on 2018/9/30.
 */
public interface ManageSynergyWorkorderServicerLogDao extends PagingAndSortingRepository<ManageSynergyWorkorderServicerLogDO, Long> {
    @Query("select count(distinct l.servicePatientCode) from ManageSynergyWorkorderServicerLogDO l where l.workorderCode=?1 and l.followUp=2 ")
    Integer findByWorkorderCodeAndFollowUp(String workorderCode);
    @Query("select count(distinct l.servicePatientCode) from ManageSynergyWorkorderServicerLogDO l where l.workorderCode=?1 and l.returnVisit=2 ")
    Integer findByWorkorderCodeAndReturnVisit(String workorderCode);
}

+ 9 - 10
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateQuestionService.java

@ -1,12 +1,11 @@
package com.yihu.wlyy.service.manager.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestion;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionDao;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionsDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@ -14,9 +13,9 @@ import java.util.List;
 * Created by ysj on 2017/3/3.
 */
@Service
public class SurveyTemplateQuestionService extends BaseJpaService<SurveyTemplateQuestion,Long> {
public class SurveyTemplateQuestionService extends BaseJpaService<SurveyTemplateQuestions,Long> {
    @Autowired
    SurveyTemplateQuestionDao surveyTemplateQuestionDao;
    SurveyTemplateQuestionsDao surveyTemplateQuestionDao;
    /**
     * 根据模板code删除数据
@ -36,19 +35,19 @@ public class SurveyTemplateQuestionService extends BaseJpaService<SurveyTemplate
     * @param templateCode
     * @return
     */
    public List<SurveyTemplateQuestion> findByTemplateCode(String templateCode){
    public List<SurveyTemplateQuestions> findByTemplateCode(String templateCode){
        return surveyTemplateQuestionDao.findByTemplateCodeAndDel(templateCode,"1");
    }
    public void save(List<SurveyTemplateQuestion> surveyTemplateQuestions){
    public void save(List<SurveyTemplateQuestions> surveyTemplateQuestions){
        surveyTemplateQuestionDao.save(surveyTemplateQuestions);
    }
    public SurveyTemplateQuestion save(SurveyTemplateQuestion surveyTemplateQuestion){
       return surveyTemplateQuestionDao.save(surveyTemplateQuestion);
    public SurveyTemplateQuestions save(SurveyTemplateQuestions surveyTemplateQuestions){
       return surveyTemplateQuestionDao.save(surveyTemplateQuestions);
    }
    public SurveyTemplateQuestion findByCode(String code){
    public SurveyTemplateQuestions findByCode(String code){
        return  surveyTemplateQuestionDao.findByCode(code);
    }
}

+ 4 - 4
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateService.java

@ -5,7 +5,7 @@ import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.survey.SurveyLabelInfo;
import com.yihu.wlyy.entity.survey.SurveyTemplate;
import com.yihu.wlyy.entity.survey.SurveyTemplateOption;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestion;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.repository.SystemDictDao;
import com.yihu.wlyy.repository.survey.SurveyTemplateDao;
import com.yihu.wlyy.service.manager.user.UserService;
@ -57,7 +57,7 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
    public SurveyTemplate saveOrUpdate(String jsonData,String loginUserId){
        JSONArray array = new JSONArray(jsonData);
        List<SurveyTemplate> surveyTemplates = new ArrayList<>();
        List<SurveyTemplateQuestion> surveyTemplateQuestions = new ArrayList<>();
        List<SurveyTemplateQuestions> surveyTemplateQuestions = new ArrayList<>();
        List<SurveyTemplateOption> surveyTemplateOptions = new ArrayList<>();
        List<SurveyLabelInfo> surveyLabelInfos = new ArrayList<>();
        SurveyTemplate surveyTemplate = null;
@ -87,7 +87,7 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
            if(!jsonObject.isNull("questions")){
                JSONArray questionsArray = (JSONArray)jsonObject.get("questions");
                for(Object questionObj:questionsArray){
                    SurveyTemplateQuestion surveyTemplateQuestion = new SurveyTemplateQuestion();
                    SurveyTemplateQuestions surveyTemplateQuestion = new SurveyTemplateQuestions();
                    JSONObject questionJson = (JSONObject)questionObj;
                    clazzReflect.formatToClazz(surveyTemplateQuestion,questionJson);
                    surveyTemplateQuestion.setCreateTime(new Date());
@ -206,7 +206,7 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
        if(surveyTemplate==null) throw new  RuntimeException("模板不存在!");
        JSONObject surveyTemplateJson = new JSONObject(surveyTemplate);
        if(loadQuestion==1l){
            List<SurveyTemplateQuestion> surveyTemplateQuestions = this.surveyTemplateQuestionService.findByTemplateCode(surveyTemplate.getCode());
            List<SurveyTemplateQuestions> surveyTemplateQuestions = this.surveyTemplateQuestionService.findByTemplateCode(surveyTemplate.getCode());
            JSONArray questions = new JSONArray(surveyTemplateQuestions);

+ 176 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/QuestionnaireManageService.java

@ -0,0 +1,176 @@
package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.survey.SurveyQuestionResult;
import com.yihu.wlyy.entity.survey.SurveyTemplateQuestions;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.survey.SurveyQuestionResultDao;
import com.yihu.wlyy.repository.survey.SurveyTemplateQuestionsDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkOrderDao;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerDao;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
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 java.util.*;
/**
 * Created by humingfen on 2018/09/27.
 */
@Service
@Transactional
public class QuestionnaireManageService extends BaseJpaService {
    @Value("${wlyy.url}")
    private String wlyyUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ManageSynergyWorkOrderDao workOrderDao;
    @Autowired
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    @Autowired
    private SurveyTemplateQuestionsDao templateQuestionDao;
    @Autowired
    private SurveyQuestionResultDao questionResultDao;
    /**
     * 创建协同服务
     * @param workorderDO
     * @param workorderServicerDOS
     * @return
     */
    public boolean createWorkOrder(ManageSynergyWorkorderDO workorderDO, List<ManageSynergyWorkorderServicerDO> workorderServicerDOS) {
        String servicer = "";
        int size = workorderServicerDOS.size();
        int len = 0;
        if(size > 5){
            len = 5;
        }else {
            len = size;
        }
        //获取服务对象最多五个人
        for(int i = 0; i < len; i++){
            servicer += workorderServicerDOS.get(i).getServicePatientName() + ",";
        }
        servicer = servicer.substring(0, servicer.length()-1);
        //保存协同服务工单
        workorderDO.setCode(getCode());
        workorderDO.setStatus(1);
        workorderDO.setCreateTime(new Date());
        workorderDO.setDel(1);
        workorderDO.setServicerCount(size);
        workorderDO.setServicerKey(servicer);
        workOrderDao.save(workorderDO);
        //保存协同服务工单的服务对象
        List<ManageSynergyWorkorderServicerDO> list = new ArrayList<>();
        for(ManageSynergyWorkorderServicerDO servicerDO : workorderServicerDOS){
            servicerDO.setCode(getCode());
            servicerDO.setWorkorderType(workorderDO.getType());
            servicerDO.setWorkorderCode(workorderDO.getCode());
            servicerDO.setStatus(1);
            servicerDO.setCreateTime(new Date());
            list.add(servicerDO);
        }
        workorderServicerDao.save(list);
        return true;
    }
    /**
     * 保存问卷结果
     * @param patientCode
     * @param labelType
     * @param customerCode
     * @param source
     * @param jsonData
     * @param serviceCode
     */
    public String saveResultAndAnswer(String patientCode, Integer labelType, String customerCode, Integer source, String jsonData, String serviceCode) {
        String url = wlyyUrl + "doctor/questionnaire/saveResultAndAnswer";
        String response = "";
        Map<String, Object> params = new HashMap<>();
        params.put("labelType", labelType);
        params.put("patientCode", patientCode);
        params.put("jsonData", jsonData);
        params.put("customerCode", customerCode);
        params.put("source", source);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject object = JSONObject.parseObject(response);
        String questionResultCode = object.getString("data");
        if(StringUtils.isNotBlank(questionResultCode)) {
            workorderServicerDao.updateRelationCodeByCode(serviceCode, questionResultCode);
        }
        return questionResultCode;
    }
    /**
     * 查看调查问卷统计结果
     * @param templateCode
     * @return
     */
    public JSONObject getAnswers(String templateCode) {
        String url = wlyyUrl + "doctor/questionnaire/getAnswers?id=" + templateCode;
        String  response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功!")){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 根据问卷结果code查看居民填写问卷详情
     * @param code
     * @return
     */
    public JSONObject getReuslt(String code){
        JSONObject json = new JSONObject();
        //查找问卷结果信息
        SurveyQuestionResult questionResult = questionResultDao.findByCode(code);
        String patient = questionResult.getPatientCode();
        String templateCode = questionResult.getTemplateCode();
        //获取模板问题
        List<SurveyTemplateQuestions> questionList = templateQuestionDao.findByTemplateCode(templateCode);
        //查找选项和答案
        Map<String, Object> answerMap = new HashMap<>();
        String sql = "SELECT soa.*, sto.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_template_options sto ON soa.options_code= sto.code WHERE soa.screen_result_code = ? AND soa.patient=? AND soa.survey_code=?";
        List<Map<String, Object>> optionAnswersList = jdbcTemplate.queryForList(sql, new Object[]{code, patient, templateCode});
        for (SurveyTemplateQuestions templateQuestion : questionList) {
            Map<String, Object> map = new HashMap<>();
            map.put("question", templateQuestion);
            String qusCode = templateQuestion.getCode();
            for (Map<String, Object> option : optionAnswersList) {
                if (option.get("question_code").equals(qusCode)) {
                    map.put("option", option);
                }
            }
            answerMap.put(templateQuestion.getSort() + "", map);
        }
        json.put("answer", answerMap);
        return json;
    }
    public JSONObject getQuestionnaireDetail(String surveyCode) {
        String url = wlyyUrl + "doctor/questionnaire/getQuestionnaireDetail?id=" + surveyCode;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);
    }
}

+ 51 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/ScreenResultManageService.java

@ -0,0 +1,51 @@
package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.util.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * Created by humingfen on 2018/09/29.
 */
@Service
@Transactional
public class ScreenResultManageService {
    @Value("${wlyy.url}")
    private String wlyyUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 获取筛查结果详情
     * @param code
     * @return
     */
    public JSONObject getScreenResultDetail(String code) {
        String url = wlyyUrl + "doctor/screen/getScreenResultDetail?code=" + code;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 获取筛查问卷详情
     * @param templateCode
     * @return
     */
    public JSONObject getScreenDetail(String templateCode) {
        String url = wlyyUrl + "/doctor/questionnaire/getAllQuestions?surveyTemplateCode=" + templateCode;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = JSONObject.parseObject(response);
        if(jsonObject.getString("msg").equals("查询成功")){
            return JSONObject.parseObject(jsonObject.getString("data"));
        }
        return JSONObject.parseObject(response);
    }
}

+ 850 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -0,0 +1,850 @@
package com.yihu.wlyy.service.synergy;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkordeReminderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderExecutorDO;
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerDO;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.repository.synergy.*;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
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 java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by 刘文彬 on 2018/9/27.
 */
@Service
@Transactional
public class SynergyManageService extends BaseJpaService {
    @Value("${wlyy.url}")
    private String wlyyUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private ManageSynergyWorkOrderDao workOrderDao;
    @Autowired
    private ManageSynergyWorkorderServicerDao workorderServicerDao;
    @Autowired
    private ManageSynergyWorkorderExecutorDao workorderExecutorDao;
    @Autowired
    private UserDao userDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    private ManageSynergyWorkorderCustomerLogDao customerLogDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private ManageSynergyWorkorderReminderDao manageSynergyWorkorderReminderDao;
    @Autowired
    private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
    @Autowired
    private TownDao townDao;
    /**
     * 根据服务编码获取工单
     * @param workorderCode
     * @return
     */
    public ManageSynergyWorkorderDO findWorkOrderByCode(String workorderCode) {
        return workOrderDao.findByCode(workorderCode);
    }
    /**
     * 我接收到的任务
     * @param code
     * @param keywords
     * @param workorderType
     * @param isMyTask 是否由我负责
     * @param status
     * @param priority
     * @param timeout
     * @param workorderCode
     * @param principal
     * @param serviceStartTime
     * @param serviceEndTime
     * @param patientName
     * @param ssc 社保卡号
     * @param idcard 身份证
     * @param userType 1、医生,2、客服,3、客服管理员
     * @param isAcceptTask 1、我接收到的任务,2、我派发的任务,3、待接收(客服管理员),4、已接收(客服管理员)
     * @return
     * @throws Exception
     */
    public Map<String,Object> workorderList(String code,String keywords,Integer workorderType,
                               Integer isMyTask,Integer status,Integer priority,Integer timeout,String workorderCode,
                               String principal,String serviceStartTime,String serviceEndTime,
                               String patientName,String ssc,String idcard,Integer userType,Integer isAcceptTask,Integer page, Integer pageSize) throws Exception{
        String servicerTable = " left join wlyy.manage_synergy_workorder_executor e on e.workorder_code=w.code AND e.del = 1  " ;
        String whereSql = "";
        if(userType==3){//客服管理员
            whereSql +=" and w.create_user_type=1 ";//创建人为医生
            if(isAcceptTask==3){//待接收
                whereSql +=" and w.status =1 ";
                servicerTable ="";
            }else if(isAcceptTask==4){//已接收
                whereSql +=" and w.status in (2,3) ";
            }
        }else if(userType==2){//客服
            if(isAcceptTask==1){//我接收
                whereSql +=" and w.create_user_type=1 ";//创建人为医生
                whereSql += " and e.executor_code ='"+code+"' ";
            }else if(isAcceptTask==2){//我派发
                whereSql +=" and w.create_user_type=2 ";//创建人为客服
                whereSql += " and e.create_user ='"+code+"' ";
            }
        }else if(userType==3){//医生
            if(isAcceptTask==1){//我接收
                whereSql +=" and w.create_user_type=2 ";//创建人为客服
                whereSql += " and e.executor_code ='"+code+"' ";
            }else if(isAcceptTask==2){//我派发
                whereSql +=" and w.create_user_type=2 ";//创建人为医生
                whereSql += " and e.create_user ='"+code+"' ";
            }
        }
        //关键字查询
        if(StringUtils.isNotEmpty(keywords)){
            servicerTable +=" left join wlyy.manage_synergy_workorder_servicer s on s.workorder_code=w.code ";
            whereSql += " and w.servicer_count<=10  ";
            whereSql += " and (w.create_user_name like '%"+keywords+"%' or s.service_patient_name like '%"+keywords+"%' " +
                    " or s.ssc like '%"+keywords+"%' or s.idcard like '%"+keywords+"%' ) ";
        }
        //服务类型
        if(workorderType!=null){
            whereSql += " and w.type ="+workorderType+" ";
        }
        //是否是我负责的
        if(isMyTask!=null){
            whereSql += " and e.executor_code ='"+code+"' and e.executor_type=1 ";
        }
        //工单状态
        if(status!=null){
            whereSql +=" and w.status ="+status+" ";
        }
        //优先级
        if(priority!=null){
            whereSql+= " and w.priority="+priority+" ";
        }
        //是否超时
        if(timeout!=null){
            whereSql +=" and w.service_time >'"+DateUtil.dateToStrLong(new Date())+"' ";
        }
        //服务编码
        if(StringUtils.isNotEmpty(workorderCode)){
            whereSql+=" and w.code like '%"+workorderCode+"%' ";
        }
        //负责人
        if(StringUtils.isNotEmpty(principal)){
            whereSql+=" and e.code like '%"+principal+"%' and e.executor_type=1 ";
        }
        //服务时间
        if(StringUtils.isNotEmpty(serviceStartTime)){
            whereSql+=" and w.service_time>='"+serviceStartTime+"' ";
        }
        if(StringUtils.isNotEmpty(serviceEndTime)){
            whereSql+=" and w.service_time<='"+serviceEndTime+"' ";
        }
        //服务对象
        if(StringUtils.isNotEmpty(patientName)){
            whereSql+=" s.service_patient_name like '%"+keywords+"%' ";
        }
        //社保卡号
        if(StringUtils.isNotEmpty(ssc)){
            whereSql+=" s.ssc like '%"+keywords+"%' ";
        }
        //身份证号
        if(StringUtils.isNotEmpty(idcard)){
            whereSql+=" s.idcard like '%"+keywords+"%' ";
        }
        String sql =" select DISTINCT w.* from wlyy.manage_synergy_workorder w  " +servicerTable+
                " where w.del=1  " +
                " and 1=1 "+whereSql+ " order by w.priority desc,w.service_time desc";
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
        int count = 0;
        if(rstotal!=null&&rstotal.size()>0&&rstotal.get(0).get("id")!=null){
            count = rstotal.size();
        }
        String finalSql = sql+" LIMIT "+(page-1)*pageSize+","+pageSize;
        List<Map<String,Object>> resultWorkorderList = jdbcTemplate.queryForList(finalSql);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> one : resultWorkorderList){
            Map<String,Object> map = new HashMap<>();
            map.put("workorderCode",one.get("code"));//服务编码
            Integer workorderTypeR = (Integer) one.get("type");
            String workorderTypeName = "";
            map.put("type",workorderTypeR);//服务类型
            switch (workorderTypeR){
                case 0: workorderTypeName="咨询";break;
                case 1: workorderTypeName="健康教育";break;
                case 2: workorderTypeName="预约";break;
                case 3: workorderTypeName="随访";break;
                case 4: workorderTypeName="问卷调查";break;
                case 5: workorderTypeName="疾病筛查";break;
            }
            map.put("typeName",workorderTypeName);//服务类型名称
            map.put("serviceTime", DateUtil.dateToStr((Date)one.get("service_time"),"yyyy-MM-dd HH:mm"));//服务时间
            map.put("priority",one.get("priority"));//工单优先级
            map.put("priorityName",((Integer)one.get("priority"))==1?"加急":"普通");
            Integer overTime = isServiceOverTime((Date)one.get("service_time"));
            map.put("overTime",overTime);//是否超时
            String[] servicer = (one.get("servicer_key")+"").split(",");
            map.put("servicer",servicer[0]);//服务对象
            map.put("servicerCount",one.get("servicer_count"));//服务对象人数
            Integer statusR = (Integer) one.get("status");
            map.put("status",statusR);//工单状态
            String statusName="";
            switch (statusR){
                case 0:statusName="草稿";break;
                case 1:statusName="未接受";break;
                case 2:statusName="处理中";break;
                case 3:statusName="处理完成";break;
                case 4:statusName="退回";break;
            }
            map.put("statusName",statusName);
            List<ManageSynergyWorkorderExecutorDO> managerList = workorderExecutorDao.findByWorkorderCode(one.get("code")+"",1);
            String managerName = managerList.size()>0?managerList.get(0).getExecutorName():"";
            map.put("managerName",managerName);//负责人的名称
            Integer finishedServicerCount = workorderServicerDao.findByWorkorderCodeCount(one.get("code")+"",3);
            map.put("finishedServicerCount",finishedServicerCount);//服务完成人数
            resultList.add(map);
        }
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("currPage",page);
        resultMap.put("pageSize",pageSize);
        resultMap.put("totalCount",count);
        resultMap.put("detailModelList",resultList);
        return resultMap;
    }
    /**
     * 获取服务编码
     * @return
     */
    public synchronized String getWorkorderNo(){
        String orderNo = "" ;
        String trandNo = String.valueOf((Math.random() * 9 + 1) * 1000000);
        String sdf = new SimpleDateFormat("yyyyMMddHHMMSS").format(new Date());
        orderNo = trandNo.toString().substring(0, 4);
        orderNo = sdf + orderNo ;
        return orderNo ;
    }
    /**
     * 获取超时级别
     * @param serviceTime
     * @return
     */
    public Integer isServiceOverTime(Date serviceTime){
        //当前时间 > 服务时间+4小时(已超时)3
        //服务时间+4小时 > 当前时间 > 服务时间(红色超时)2
        //服务时间 HH:mm:59()> 当前时间 > 服务时间 HH:mm:00(黄色超时)1
        //服务时间 HH:mm:00 > 当前时间 (正常)0
        Integer serviceStatus = null;
        String serviceTimeStart = DateUtil.dateToStr(serviceTime,"yyyy-MM-dd HH:mm")+":00";
        String serviceTimeEnd = DateUtil.dateToStr(serviceTime,"yyyy-MM-dd HH:mm")+":59";
        Long serviceTimeStartLong = DateUtil.strToDate(serviceTimeStart,"yyyy-MM-dd HH:mm:ss").getTime();
        Long serviceTimeEndLong = DateUtil.strToDate(serviceTimeEnd,"yyyy-MM-dd HH:mm:ss").getTime();
        Long serviceTimeAfter4Long = serviceTimeEndLong+4*60*60*1000;
        Long currentTime = new Date().getTime();
        if(currentTime<serviceTimeStartLong){//正常
            serviceStatus=0;
        }else if(currentTime>=serviceTimeStartLong&&currentTime<=serviceTimeEndLong){//黄色超时
            serviceStatus=1;
        }else if(currentTime>serviceTimeEndLong&&currentTime<=serviceTimeAfter4Long){//红色超时
            serviceStatus=2;
        }else if(currentTime>serviceTimeAfter4Long){//已超时
            serviceStatus=3;
        }
        return serviceStatus;
    }
    /**
     * 获取系统服务详情
     * @param workorderCode
     * @param patient
     * @param role
     * @return
     */
    public Map<String, Object> getWorkOrderInfo(String workorderCode, String patient, Integer role) {
        Map<String, Object> map = new HashMap<>();
        ManageSynergyWorkorderDO workorderDO = workOrderDao.findByCode(workorderCode);
        Integer status = workorderDO.getStatus();
        //存入协同服务工单信息
        map.put("code", workorderCode);
        map.put("type", workorderDO.getType());
        map.put("priority", workorderDO.getPriority());
        map.put("serviceTime", workorderDO.getServiceTime());
        map.put("status", status);
        map.put("title", workorderDO.getRelationCodeName());
        map.put("remark", workorderDO.getRemark());
        map.put("createTime", workorderDO.getCreateTime());
        map.put("createUserName", workorderDO.getCreateUserName());
        map.put("hospitalName", workorderDO.getHospitalName());
        //获取服务对象
        if(StringUtils.isNotBlank(patient)){
            //获取单个居民处理完成的工单信息
            ManageSynergyWorkorderServicerDO workorderServicerDO = workorderServicerDao.findByWorkOrderCodeAndPatientCode(workorderCode, patient);
            map.put("servicerKey", workorderServicerDO.getServicePatientName());
            map.put("idcard", workorderServicerDO.getIdcard());
            map.put("ssc", workorderServicerDO.getSsc());
            map.put("completeTime", workorderServicerDO.getCompleteTime());
        }else {
            if(status == 2 || status == 3){
                //获取工单完成人数
                int count = workorderServicerDao.findByWorkorderCodeCount(workorderCode, 3);
                map.put("count", count);
            }
            map.put("servicerKey", workorderDO.getServicerKey());
            map.put("servicerCount", workorderDO.getServicerCount());
        }
        //超时标签
        map.put("delayStatus", this.isServiceOverTime(workorderDO.getServiceTime()));
        //根据角色显示对应工单状态
        if(workorderDO.getCreateUserType() == 1 && role == 2){
            map.put("status", "待接收");
        }else if(workorderDO.getCreateUserType() == 2 && role == 1){
            map.put("status", "未接收");
        }
        if(status == 2){
            //接收者
            map.put("receiverName", workorderDO.getReceiverName());
            map.put("receiverTime", workorderDO.getReceiverTime());
            //获取负责人信息
            List<ManageSynergyWorkorderExecutorDO> managerList = workorderExecutorDao.findByWorkorderCode(workorderCode,1);
            List<ManageSynergyWorkorderExecutorDO> collaboratorList = workorderExecutorDao.findByWorkorderCode(workorderCode,2);
            //获取负责人信息
            for(ManageSynergyWorkorderExecutorDO m : managerList){
                User manager = userDao.findByCode(m.getExecutorCode());
                map.put("managerName", manager.getName());
                map.put("managerJobNo", manager.getJobNo());
                map.put("managerPhone", manager.getMobile());
            }
            String collaborator = "";
            for(ManageSynergyWorkorderExecutorDO one : collaboratorList){
                collaborator += "、" + one.getExecutorName();
            }
            map.put("collaboratorList", StringUtils.isNotEmpty(collaborator) ? collaborator.substring(1) : "");//参与人可能有多个
        }
        if(status == 3){
            //获取处理结果
            map.put("resultRemark", workorderDO.getDealResultRemark());
            map.put("accessory", workorderDO.getDealResultAccessory());
        }else if(status == 4){
            //获取退回原因
            map.put("returnedRemark", workorderDO.getReturnedRemark());
        }
        return map;
    }
    /**
     * 协同服务取号(客服)
     * @param workorderCode
     * @param townCode
     * @param hospitalCode
     */
    public Map<String,Object> takeWorkorderNum(String workorderCode,String townCode,String hospitalCode,
                                               String diseaseCode,String healthCode,String serveCode,Integer isFollow) throws Exception{
        String whereSql ="";
        String leftSql ="";
        if(StringUtils.isNotEmpty(townCode)){
            whereSql+=" and s.town='"+townCode+"' ";
        }
        if(StringUtils.isNotEmpty(hospitalCode)){
            whereSql+=" and s.hospital='"+hospitalCode+"' ";
        }
        String labelSql ="";
        if(StringUtils.isNotEmpty(diseaseCode)||StringUtils.isNotEmpty(healthCode)||StringUtils.isNotEmpty(serveCode)){
            leftSql +=" LEFT JOIN wlyy_sign_patient_label_info i on i.patient=s.service_patient_code and i.status=1 " ;
            if(StringUtils.isNotEmpty(diseaseCode)){
                labelSql+=" or (i.label='"+diseaseCode+"' and i.label_type='3') ";//疾病类型
            }
            if(StringUtils.isNotEmpty(healthCode)){
                labelSql+=" or (i.label='"+healthCode+"' and i.label_type='2') ";//健康情况
            }
            if(StringUtils.isNotEmpty(serveCode)){
                labelSql+=" or (i.label='"+serveCode+"' and i.label_type='1') ";//服务类型
            }
        }
        if(StringUtils.isNotEmpty(labelSql)){
            whereSql+= " and ( "+labelSql.substring(3)+" )";
        }
        if(isFollow!=null&&isFollow==1){//跟进
            leftSql+=" LEFT JOIN manage_synergy_workorder_servicer_log ll on ll.service_patient_code=s.code ";
            whereSql+=" and ll.follow_up=2 ";
        }
        String sql =" select DISTINCT w.*,s.mobile,s.service_patient_name,s.service_patient_code,s.code as servicerCode,s.town_name,s.hospital_name " +
                " w.create_user_name " +
                " from manage_synergy_workorder_servicer s " +
                " LEFT JOIN manage_synergy_workorder w on s.workorder_code=w.code " +
                " LEFT JOIN manage_synergy_workorder_executor e on e.workorder_code=w.code " + leftSql+
                " LEFT JOIN manage_synergy_workorder_customer_log l on l.service_patient_code=s.service_patient_code " +
                " where s.status=1  and s.workorderCode='"+workorderCode+"' " +
                " and w.del=1 and w.status=2 and e.del=1 "+
                whereSql+" order by l.id desc";
        List<Map<String,Object>> resultWorkorderList = jdbcTemplate.queryForList(sql);
        Map<String,Object> resultMap = new HashMap<>();
        if(resultWorkorderList.size()>0){
            Map<String,Object> workorderMap = resultWorkorderList.get(0);
            //居民信息
            resultMap.put("mobile",workorderMap.get("mobile"));//电话号码
            resultMap.put("patientName",workorderMap.get("service_patient_name"));//居民姓名
            Integer callNum = customerLogDao.callNumByWorkorder(workorderMap.get("servicerCode")+"");
            resultMap.put("callNum",callNum);//已呼叫次数
            resultMap.putAll(this.getPatientInfo(workorderMap.get("service_patient_code") + ""));
            /*Patient patient =patientDao.findByCode(workorderMap.get("service_patient_code")+"");
            Integer sex = patient.getSex();
            String sexName ="";
            if(sex==1){
                sexName="男";
            }else if(sex==2){
                sexName="女";
            }else{
                sexName="未知";
            }
            resultMap.put("sex",sexName);//性别
            Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
            resultMap.put("age",age);//年龄
            resultMap.put("townName",workorderMap.get("town_name"));//所属区县
            resultMap.put("hospitalName",workorderMap.get("hospital_name"));//所属社区
            SignFamily signFamily = signFamilyDao.findSignByPatient(workorderMap.get("service_patient_code")+"");
            resultMap.put("signDoctor",signFamily.getDoctor());//签约医生(即:工单创建医生)
            resultMap.put("healthDoctor",signFamily.getDoctorHealthName());//健管师
            List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"",  "3", 1);
            String diseaseType="";
            for(SignPatientLabelInfo one:labelDiseaseType){
                diseaseType+=","+one.getLabelName();
            }
            resultMap.put("diseaseType",StringUtils.isNotEmpty(diseaseType)?diseaseType.substring(1):"");//疾病类型
            List<SignPatientLabelInfo> labelHealthType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"",  "2", 1);
            String healthType="";
            for(SignPatientLabelInfo one:labelHealthType){
                healthType+=","+one.getLabelName();
            }
            resultMap.put("healthType",StringUtils.isNotEmpty(healthType)?healthType.substring(1):"");//健康情况
            List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(workorderMap.get("service_patient_code")+"",  "2", 1);
            String serveType="";
            for(SignPatientLabelInfo one:labelServeType){
                serveType+=","+one.getLabelName();
            }
            resultMap.put("serveType",StringUtils.isNotEmpty(serveType)?serveType.substring(1):"");//服务类型*/
            return resultMap;
        }else{
            throw new Exception("没有任务");
        }
    }
    /**
     * 将管理员接收或者退回操作存入数据库
     * @param code
     * @param user
     * @param jsonData
     * @param status
     */
    public void dealWorkOrder(String code, User user, String jsonData, Integer status) {
        ManageSynergyWorkorderDO workorderDO = workOrderDao.findByCode(code);
        workorderDO.setStatus(status);
        workorderDO.setReceiverType(user.getType());
        workorderDO.setReceiverCode(user.getCode());
        workorderDO.setReceiverName(user.getName());
        JSONObject jsonObject = new JSONObject(jsonData);
        if(status == 4){
            workorderDO.setReturnedRemark(jsonObject.getString("returnedRemark"));
            this.sendMessage(workorderDO, null, 26);
        }else if(status == 2){
            //创建负责人信息
            List<ManageSynergyWorkorderExecutorDO> list = new ArrayList<>();
            String manager = jsonObject.getString("manager");
            String[] managers = manager.split(",");
            for(String m : managers){
                ManageSynergyWorkorderExecutorDO executorDO = new ManageSynergyWorkorderExecutorDO();
                User managerUser = userDao.findByCode(m);
                executorDO.setCode(getCode());
                executorDO.setWorkorderCode(code);
                executorDO.setExecutorType(1);
                executorDO.setExecutorCode(m);
                executorDO.setExecutorName(managerUser.getName());
                executorDO.setDel(1);
                list.add(executorDO);
                this.sendMessage(workorderDO, managerUser, 25);
            }
            //保存协作者信息
            String collaborator = jsonObject.getString("collaborator");
            String[] collaborators = manager.split(",");
            for(String c : collaborators){
                ManageSynergyWorkorderExecutorDO executorDO = new ManageSynergyWorkorderExecutorDO();
                User u = userDao.findByCode(c);
                executorDO.setCode(getCode());
                executorDO.setWorkorderCode(code);
                executorDO.setExecutorType(1);
                executorDO.setExecutorCode(c);
                executorDO.setExecutorName(u.getName());
                executorDO.setDel(1);
                list.add(executorDO);
            }
            workorderExecutorDao.save(list);
        }
        workOrderDao.save(workorderDO);
    }
    /**
     * 发送消息
     * @param workorderDO
     * @param user
     * @param type
     */
    public void sendMessage(ManageSynergyWorkorderDO workorderDO, User user, Integer type){
        String url = wlyyUrl + "doctor/message/sendMessage";
        //组装message内容
        JSONObject message = new JSONObject();
        if(type == 24){
            message.put("receiver", workorderDO.getReceiverCode());
            message.put("sender", workorderDO.getCreateUser());
            message.put("type", type);
            message.put("relationCode", workorderDO.getCode());
        }else {
            message.put("sender", workorderDO.getReceiverCode());
            message.put("receiver", workorderDO.getCreateUser());
            message.put("type", type);
            message.put("relationCode", workorderDO.getCode());
        }
        //组装jsonObject内容
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("type", workorderDO.getType());
        if(type == 26){
            jsonObject.put("returnedRemark", workorderDO.getReturnedRemark());
        }else if(type == 25){
            jsonObject.put("customerName", user.getName());
            jsonObject.put("phone", user.getMobile());
        }
        Map<String, Object> params = new HashMap<>();
        params.put("message", message.toString());
        params.put("jsonObject", jsonObject.toString());
        try {
            String response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 查找该客服该工单是否有异常工单
     * @param workorderCode
     * @param customerCode
     * @return
     */
    public Integer findExceptionCount(String workorderCode, String customerCode) {
        return customerLogDao.findExceptionCount(workorderCode, customerCode);
    }
    public Map<String, Object> loadingInfo(String workorderCode, String customerCode) {
        Map<String,Object> resultMap = new HashMap<>();
        String sql = "SELECT s.service_patient_name, s.service_patient_code, s.`code`, s.s.hospital_name,s.town_name " +
                "from (SELECT DISTINCT r.patient,cl.workorder_code from manage_synergy_workorder_customer_log cl " +
                "LEFT JOIN manage_call_record r on cl.call_code = r.`code` " +
                "where cl.workorder_code = " + workorderCode + " and cl.create_user_code = " + customerCode + " and cl.`status` = 0 ORDER BY cl.create_time LIMIT 0,1) p " +
                "LEFT JOIN manage_synergy_workorder_servicer s on p.workorder_code = s.workorder_code and s.service_patient_code = p.patient and s.`status`=1";
        Map<String, Object> result = (Map<String, Object>) jdbcTemplate.queryForList(sql);
        String patientCode = (String) result.get("service_patient_name");
        resultMap.put("patientName", patientCode);
        resultMap.put("townName", result.get("town_name"));//所属区县
        resultMap.put("hospitalName", result.get("hospital_name"));//所属社区
        Integer callNum = customerLogDao.callNumByWorkorder((String) result.get("code"));
        resultMap.put("callNum",callNum);//已呼叫次数
        resultMap.putAll(this.getPatientInfo(patientCode));
        return resultMap;
    }
    public Map<String,Object> getPatientInfo(String patientCode){
        Map<String, Object> resultMap = new HashMap<>();
        Patient patient = patientDao.findByCode(patientCode);
        Integer sex = patient.getSex();
        String sexName = "";
        if(sex == 1){
            sexName = "男";
        }else if(sex == 2){
            sexName = "女";
        }else{
            sexName = "未知";
        }
        resultMap.put("sex", sexName);//性别
        Integer age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
        resultMap.put("age",age);//年龄
        SignFamily signFamily = signFamilyDao.findSignByPatient(patientCode);
        resultMap.put("signDoctor", signFamily.getDoctor());//签约医生(即:工单创建医生)
        resultMap.put("healthDoctor", signFamily.getDoctorHealthName());//健管师
        List<SignPatientLabelInfo> labelDiseaseType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "3", 1);
        String diseaseType="";
        for(SignPatientLabelInfo one:labelDiseaseType){
            diseaseType+=","+one.getLabelName();
        }
        resultMap.put("diseaseType", StringUtils.isNotEmpty(diseaseType) ? diseaseType.substring(1) : "");//疾病类型
        List<SignPatientLabelInfo> labelHealthType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "2", 1);
        String healthType="";
        for(SignPatientLabelInfo one:labelHealthType){
            healthType += ","+one.getLabelName();
        }
        resultMap.put("healthType", StringUtils.isNotEmpty(healthType) ? healthType.substring(1) : "");//健康情况
        List<SignPatientLabelInfo> labelServeType = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patientCode,  "2", 1);
        String serveType="";
        for(SignPatientLabelInfo one:labelServeType){
            serveType+=","+one.getLabelName();
        }
        resultMap.put("serveType", StringUtils.isNotEmpty(serveType)?serveType.substring(1) : "");//服务类型
        return resultMap;
    }
    /**
     * 任务进度
     * @param workorderCode
     * @param userCode
     */
    public Map<String,Object> workorderRate(String workorderCode,String userCode){
        Map<String,Object> resultMap = new HashMap<>();
        //完成情况
        //1、有效
        Integer validCount = workorderServicerDao.findByWorkorderCodeCount(workorderCode,3);
        resultMap.put("validCount",validCount);
        //2、无效
        resultMap.put("invalidCount",0);
        //3、总数
        ManageSynergyWorkorderDO manageSynergyWorkorder = workOrderDao.findByCode(workorderCode);
        resultMap.put("allCount",manageSynergyWorkorder.getServicerCount());
        //我已完成
        Integer myFinishedCount = workorderServicerDao.countByWorkorderCodeAndExecutorCodeAndStatus(workorderCode,userCode,3);
        resultMap.put("myFinishedCount",myFinishedCount);
        //待跟进
        Integer followCount = manageSynergyWorkorderServicerLogDao.findByWorkorderCodeAndFollowUp(workorderCode);
        resultMap.put("followCount",followCount);
        return resultMap;
    }
    /**
     * 催单
     * @param workorderCode
     * @param userCode
     * @param userType
     * @throws Exception
     */
    @Transactional
    public void reminder(String workorderCode,String userCode,Integer userType) throws Exception{
        ManageSynergyWorkorderDO manageSynergyWorkorderDO = workOrderDao.findByCode(workorderCode);
        if(manageSynergyWorkorderDO==null){
            throw new Exception();
        }
        ManageSynergyWorkordeReminderDO workordeReminderDO = new ManageSynergyWorkordeReminderDO();
        workordeReminderDO.setCode(getCode());
        workordeReminderDO.setWorkorderCode(workorderCode);
        workordeReminderDO.setCreateUser(userCode);
        //创建人类型(1、医生,2、客服,3、客服负责人)
        if(userType==1){
            Doctor doctor = doctorDao.findByCode(userCode);
            workordeReminderDO.setCreateUserName(doctor.getName());
        }else if(userType==2||userType==3){
            User user = userDao.findByCode(userCode);
            workordeReminderDO.setCreateUserName(user.getName());
        }
        workordeReminderDO.setCreateUserType(userType);
        workordeReminderDO.setHospital(manageSynergyWorkorderDO.getHospital());
        workordeReminderDO.setHospitalName(manageSynergyWorkorderDO.getHospitalName());
        workordeReminderDO.setCreateTime(new Date());
        List<ManageSynergyWorkorderExecutorDO> list = workorderExecutorDao.findByWorkorderCode(workorderCode,1);
        if(list!=null&&list.size()>0){
            workordeReminderDO.setPrincipalCode(list.get(0).getExecutorCode());
            workordeReminderDO.setPrincipalName(list.get(0).getExecutorName());
        }
        workordeReminderDO.setWorkorderType(manageSynergyWorkorderDO.getType());
        workordeReminderDO.setRelationCode(manageSynergyWorkorderDO.getRelationCode());
        workordeReminderDO.setRelationCodeName(manageSynergyWorkorderDO.getRelationCodeName());
        workordeReminderDO.setServiceTime(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getServiceTime():null);
        workordeReminderDO.setServicerKey(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getServicerKey():null);
        workordeReminderDO.setWorkorderRemark(manageSynergyWorkorderDO!=null?manageSynergyWorkorderDO.getRemark():null);
        workordeReminderDO.setDealWith(0);
        workordeReminderDO.setPriority(manageSynergyWorkorderDO.getPriority());
        manageSynergyWorkorderReminderDao.save(workordeReminderDO);
    }
    /**
     * 催单列表
     * @param userCode
     * @param receiveType 1、客服,2、客服负责人
     * @param sortType 1、升序,2、降序
     */
    public List<Map<String,Object>> reminderList(String userCode,Integer receiveType,Integer sortType){
        String sql ="";
        String sort ="";
        if(sortType==1){
            sort=" order by r.create_time asc ";
        }else if(sortType==2){
            sort=" order by r.create_time desc ";
        }
        if(receiveType==1){
            sql =" select DISTINCT r.* from manage_synergy_workorder_reminder r " +
                 " LEFT JOIN manage_synergy_workorder_executor e on r.workorder_code=e.workorder_code " +
                 " where e.executor_code='' and e.del=1 and r.deal_with=0 " +sort;
        }else if(receiveType==2){
            sql =" select r.* from manage_synergy_workorder_reminder r where r.principal_code='"+userCode+"' and r.deal_with=0 "+sort;
        }
        List<Map<String,Object>> List = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> resultList = new ArrayList<>();
        for(Map<String,Object> one:List){
            Map<String,Object> resultMap = new HashMap<>();
            resultMap.put("workorderCode",one.get("workorder_code"));
            resultMap.put("title","来自"+one.get("create_user_name")+"医生("+one.get("hospital_name")+")催单,请尽快处理(服务编号:)"+one.get("workorder_code"));//标题
            String workorderTypeName ="";
            Integer workorderType = (Integer) one.get("workorder_type");
            switch (workorderType){
                case 0: workorderTypeName="咨询";break;
                case 1: workorderTypeName="健康教育";break;
                case 2: workorderTypeName="预约";break;
                case 3: workorderTypeName="随访";break;
                case 4: workorderTypeName="问卷调查";break;
                case 5: workorderTypeName="疾病筛查";break;
            }
            resultMap.put("workorderTypeName",workorderTypeName);
            resultMap.put("workorderType",one.get("workorder_type"));
            resultMap.put("priority",one.get("priority"));
            resultMap.put("relationCodeName",one.get("relation_code_name"));
            resultMap.put("serviceTime",DateUtil.dateToStr((Date)one.get("service_time"),"yyyy-MM-dd HH:mm:ss"));
            resultMap.put("reminderTime",DateUtil.dateToStr((Date)one.get("create_time"),"yyyy-MM-dd HH:mm:ss"));
            resultMap.put("servicerKey",one.get("servicer_key"));
            resultMap.put("workorderRemark",one.get("workorder_remark"));
            Integer overTimeFlag = isServiceOverTime((Date)one.get("service_time"));
            resultMap.put("overTimeFlag",overTimeFlag);
            resultList.add(resultMap);
        }
        return resultList;
    }
    /**
     * 创建工单
     *
     * @param manageSynergyWorkorderDO
     * @param manageSynergyWorkorderServicerDOS
     */
    public void createWorkorder(ManageSynergyWorkorderDO manageSynergyWorkorderDO,List<ManageSynergyWorkorderServicerDO> manageSynergyWorkorderServicerDOS){
        manageSynergyWorkorderDO.setCode(getWorkorderNo());
        ManageSynergyWorkorderDO manageSynergyWorkorderDO1 = workOrderDao.save(manageSynergyWorkorderDO);
        for (ManageSynergyWorkorderServicerDO servicerDO:manageSynergyWorkorderServicerDOS){
            servicerDO.setWorkorderType(manageSynergyWorkorderDO1.getType());
            servicerDO.setWorkorderCode(manageSynergyWorkorderDO1.getCode());
            servicerDO.setRelationCode(manageSynergyWorkorderDO1.getRelationCode());
            servicerDO.setCreateTime(new Date());
            servicerDO.setRelationCodeName(manageSynergyWorkorderDO1.getRelationCodeName());
            workorderServicerDao.save(servicerDO);
        }
    }
    /**
     * 添加随访计划
     *
     * @param doctor
     * @param patient
     * @param date
     * @param followupType
     * @param followupClass
     * @param followupManagerStatus
     * @param plandate
     * @param prescriptioncode
     */
    public String addFollowup(String doctor,String patient, String date, String followupType,String followupClass,String followupManagerStatus,String plandate,String prescriptioncode){
        String response = null;
        String url = wlyyUrl + "followup/addFollowup";
        Map<String, Object> params = new HashMap<>();
        params.put("doctor",doctor);
        params.put("patient",patient);
        params.put("date",date);
        params.put("followupType",followupType);
        params.put("followupClass",followupClass);
        params.put("followupManagerStatus",followupManagerStatus);
        params.put("plandate",plandate);
        params.put("prescriptioncode",prescriptioncode);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }
    /**
     * 保存随访数据
     *
     * @param followup
     * @return
     */
    public String saveFollowupProjectData(String followup){
        String response = null;
        String url = wlyyUrl + "followup/saveFollowupProjectData";
        Map<String, Object> params = new HashMap<>();
        params.put("followup",followup);
        try {
            response = httpClientUtil.post(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }
    @Transactional
    public void taskSubmit(String workorderCode,String dealResultRemark,String dealResultAccessory) throws Exception{
        ManageSynergyWorkorderDO manageSynergyWorkorderDO = workOrderDao.findByCode(workorderCode);
        manageSynergyWorkorderDO.setDealResultRemark(dealResultRemark);
        manageSynergyWorkorderDO.setDealResultAccessory(dealResultAccessory);
        manageSynergyWorkorderDO.setStatus(3);
        workOrderDao.save(manageSynergyWorkorderDO);
    }
    public JSONObject getLabels(String labelType) {
        String url = wlyyUrl + "/wlyygc/doctor/label/labels?labelType=" + labelType;
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = new JSONObject(response);
        return  jsonObject;
    }
    public JSONObject getUnitLabels(String currentRoleCode) {
        String url = wlyyUrl + "/wlyygc/doctor/label/unitLabels?currentRoleCode=" + currentRoleCode + "&currentRoleLevel=3";
        String response = httpClientUtil.get(url, "UTF-8");
        JSONObject jsonObject = new JSONObject(response);
        return  jsonObject;
    }
    public List<Town> getTowns() {
        return (List<Town>) townDao.findAll();
    }
}

+ 35 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/synergy/SynergyWorkorderServicerLogService.java

@ -0,0 +1,35 @@
package com.yihu.wlyy.service.synergy;/**
 * Created by nature of king on 2018/10/9.
 */
import com.yihu.wlyy.entity.synergy.ManageSynergyWorkorderServicerLogDO;
import com.yihu.wlyy.repository.synergy.ManageSynergyWorkorderServicerLogDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
 * @author wangzhinan
 * @create 2018-10-09 15:58
 * @desc 协同服务处理操作日志
 **/
@Service
@Transactional
public class SynergyWorkorderServicerLogService extends BaseJpaService {
    @Autowired
    private ManageSynergyWorkorderServicerLogDao manageSynergyWorkorderServicerLogDao;
    /**
     * 添加协同服务处理操作日志
     *
     * @param synergyWorkorderServicerLogDO
     */
    public void create(ManageSynergyWorkorderServicerLogDO synergyWorkorderServicerLogDO){
        synergyWorkorderServicerLogDO.setCreateTime(new Date());
        manageSynergyWorkorderServicerLogDao.save(synergyWorkorderServicerLogDO);
    }
}

+ 40 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java

@ -110,6 +110,46 @@ public class HttpClientUtil {
		}
	}
	/**
	 * http调用方法
	 *
	 * @param url
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public  String post(String url, Map<String, Object> params) throws Exception {
		CloseableHttpClient httpclient = HttpClients.createDefault();
		RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(30000).setConnectTimeout(10000).build();//设置请求和传输超时时间
		try {
			HttpPost httpPost = new HttpPost(url);
			httpPost.setConfig(requestConfig);
			if (params != null && params.size() > 0) {
				List<NameValuePair> valuePairs = new ArrayList<NameValuePair>(params.size());
				for (Map.Entry<String, Object> entry : params.entrySet()) {
					NameValuePair nameValuePair = new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue()));
					valuePairs.add(nameValuePair);
				}
				UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(valuePairs, "UTF-8");
				httpPost.setEntity(formEntity);
			}
			CloseableHttpResponse resp = httpclient.execute(httpPost);
			try {
				HttpEntity entity = resp.getEntity();
				String respContent = EntityUtils.toString(entity, "UTF-8").trim();
				return respContent;
			} finally {
				resp.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			httpclient.close();
		}
	}
	/**
	 * 发送get请求
	 * @param url 请求地址

+ 39 - 12
patient-co-manage/wlyy-manage/src/main/resources/application.yml

@ -60,17 +60,17 @@ spring:
  profiles: dev
  datasource:
    wlyy:
      url: jdbc:mysql://172.19.103.85:3306/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
      url: jdbc:mysql://172.19.103.77/wlyy?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: root
      password: 123456
    device:
      url: jdbc:mysql://172.19.103.85:3306/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
      url: jdbc:mysql://172.19.103.77/device?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: root
      password: 123456
    medicine:
      url: jdbc:mysql://172.19.103.85:3306/medicine?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
      url: jdbc:mysql://172.19.103.77/jkedudb?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: root
      password: 123456
  sms: # SMS短信配置
    yihu_sms_url: https://smsapi.ums86.com:9600/sms/Api/Send.do
    yihu_sms_code: 229336
@ -104,7 +104,9 @@ reservation:
healthbank:
  url: http://172.19.103.33:8660/svr-wlyy-health-bank/svr-health-bank/
#  url: http://192.168.131.133:10051/svr-health-bank/
#i健康1.0接口
wlyy:
  url: http://localhost:8080/
wechat:
  appId: wxd03f859efdf0873d
  appSecret: 2935b54b53a957d9516c920a544f2537
@ -163,7 +165,14 @@ es:
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl
pushMes:
  # 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription
putMesType:
  #推送到redis消息类型
  wechat: wechat
---
spring:
  profiles: test
@ -212,6 +221,9 @@ reservation:
#健康活动url
healthbank:
  url: http://172.19.103.33:8660/svr-wlyy-health-bank/svr-health-bank/
#i健康1.0接口
wlyy:
  url: http://localhost:8080/
wechat:
  appId: wx1f129f7b51701428
  appSecret: 988f005d8309ed1795939e0f042431fb
@ -270,7 +282,14 @@ es:
  host:  http://172.19.103.68:9200
  tHost: 172.19.103.68:9300
  clusterName: jkzl
pushMes:
  # 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription
putMesType:
  #推送到redis消息类型
  wechat: wechat
---
spring:
  profiles: prod
@ -377,3 +396,11 @@ es:
  host:  http://59.61.92.90:9065,http://59.61.92.90:9067
  tHost: 59.61.92.90:9066,59.61.92.90:9068
  clusterName: jkzl
pushMes:
  # 1为推送redis,0为推送消息队列
  method: 0
  # redis队列名称
  redis_prescription_title: redisPrescription
putMesType:
  #推送到redis消息类型
  wechat: wechat

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_create_js.jsp

@ -117,7 +117,7 @@
						//厂家代码
						values.manufacturerId = $("#sel_manufacturer").ligerComboBox("getValue");
						values.deviceModel = $("#inp_deviceModel").ligerComboBox("getValue");
						if (!validator.validate()) {
							return;
						}

+ 21 - 6
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/JMController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.controller;
import com.google.gson.JsonObject;
import com.yihu.wlyy.service.common.model.Result;
import com.yihu.wlyy.service.entity.PatientReservation;
import com.yihu.wlyy.service.service.JMService;
@ -8,6 +9,7 @@ import com.yihu.wlyy.service.service.guahao.GuahaoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -312,8 +314,12 @@ public class JMController {
	{
		try {
			String data = jmService.findMyVaccin(deptNum,etmykh);
			return Result.success("查询儿童可预约疫苗成功!",data);
			JSONObject jsonObject = new JSONObject(data);
			if (jsonObject.getInt("msgCode")==800){
				return Result.success("查询儿童可预约疫苗成功!",data);
			}else {
				return Result.error(jsonObject.getString("msg"));
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
@ -327,23 +333,32 @@ public class JMController {
	{
		try {
			String data = jmService.findDept(etmykh);
			return Result.success("获取接种门诊成功!",data);
			JSONObject jsonObject = new JSONObject(data);
			if (jsonObject.getInt("msgCode")==800){
				return Result.success("获取接种门诊成功!",data);
			}else {
				return Result.error(jsonObject.getString("msg"));
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	@RequestMapping(value = "/imm/findWzymBymykh",method = RequestMethod.POST)
	@RequestMapping(value = "/imm/findYzymBymykh",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("计免:根据免疫卡号查询接种记录")
	public Result findWzymBymykh(@RequestParam(value = "etmykh")String etmykh)
	{
		try {
			String data = jmService.findWzymBymykh(etmykh);
			JSONObject jsonObject = new JSONObject(data);
			if (jsonObject.getInt("msgCode")==800){
				return Result.success("获取接种记录成功!",data);
			}else{
				return Result.error(jsonObject.getString("msg"));
			}
			return Result.success("获取接种记录成功!",data);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());

+ 14 - 9
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/JMService.java

@ -42,7 +42,7 @@ public class JMService {
    private String FIND_MY_VACCIN="findMyVaccin";
    private String FIND_CHILDREN = "findChildren";
    private String FIND_DEPT="findDept";//获取接种门诊
    private String FIND_WZYM_BY_MYKH="findWzymBymykh";
    private String FIND_WZYM_BY_MYKH="findYzymBymykh";
    private String redis_key ="imm:imm_token_key";
@ -449,11 +449,16 @@ public class JMService {
     * @return
     */
    public String getToken() throws Exception  {
        String result = "";
        Map<String,String> params = new HashMap<>();
        params.put("act", GET_TOKEN);
        params.put("accId", accId);
        return ylzImmGetSecond("getToken","计免预约-获取口令",params);
        String token = redisTemplate.opsForValue().get(redis_key);
        if (StringUtils.isEmpty(token)){
            Map<String,String> params = new HashMap<>();
            params.put("act", GET_TOKEN);
            params.put("accId", accId);
            return ylzImmGetSecond("getToken","计免预约-获取口令",params);
        }else {
            return token;
        }
    }
    /**
@ -493,7 +498,7 @@ public class JMService {
        params.put("act", FIND_MY_VACCIN);
        params.put("accId", accId);
        params.put("token", getTokenCheck());
        params.put("token_ylz", getTokenCheck());
        params.put("deptNum",deptNum);
        params.put("etmykh", etmykh);
        //params.put("etmykh", "0052182708");
@ -511,7 +516,7 @@ public class JMService {
        Map<String,String> params = new HashMap<>();
        params.put("act", FIND_DEPT);
        params.put("accId", accId);
        params.put("token", getTokenCheck());
        params.put("token_ylz", getTokenCheck());
        params.put("etmykh", etmykh);
        //params.put("etmykh", "0052182708");
        return ylzImmGetSecond(FIND_DEPT,"计免预约-获取接种门诊",params);
@ -528,7 +533,7 @@ public class JMService {
        Map<String,String> params = new HashMap<>();
        params.put("act", FIND_WZYM_BY_MYKH);
        params.put("accId", accId);
        params.put("token", getTokenCheck());
        params.put("token_ylz", getTokenCheck());
        params.put("etmykh", etmykh);
        //params.put("etmykh", "0052182708");
        /*params.put("act", "findWzymBymykh");

+ 3 - 3
patient-co-service/wlyy_service/src/main/resources/application.yml

@ -76,7 +76,7 @@ im:
  data_base_name: im_new
imm:
  url: imm
  url: jhmy
  credential: <root><org code="jkzl" /><visitor type="0" code="jkzl" key="jkzl" /></root>
zyapi:
@ -121,7 +121,7 @@ im:
  data_base_name: im_new
imm:
  url: imm
  url: jhmy
  credential: <root><org code="jkzl" /><visitor type="0" code="jkzl" key="jkzl" /></root>
zyapi:
@ -165,7 +165,7 @@ im:
  data_base_name: im_new
imm:
  url: imm
  url: jhmy
  credential: <root><org code="jkzl" /><visitor type="0" code="jkzl" key="jkzl" /></root>
zyapi:

+ 2 - 2
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/WlyySignApplication.java

@ -47,8 +47,8 @@ public class WlyySignApplication extends SpringBootServletInitializer {
        //加载续签数据
       /* Thread loadRenewSignThread = new Thread(new LoadRenewSignThread());
        loadRenewSignThread.start();*/
        Thread loadRenewSignThread = new Thread(new LoadRenewSignThread());
        loadRenewSignThread.start();
        return application.sources(WlyySignApplication.class);
    }

+ 2 - 11
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/controller/FamilyLianqianController.java

@ -2,18 +2,9 @@ package com.yihu.wlyy.sign.controller;/**
 * Created by nature of king on 2018/8/10.
 */
import com.yihu.wlyy.sign.common.model.Result;
import com.yihu.wlyy.sign.service.FamilyLianQianService;
import com.zoe.phip.ssp.sdk.ApiException;
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.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;
/**
 * @author wangzhinan
@ -25,7 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Api(description = "家庭成员信息")
public class FamilyLianqianController {
    @Autowired
    /*@Autowired
    private FamilyLianQianService service;
    @RequestMapping(value = "select",method = RequestMethod.POST)
@ -51,5 +42,5 @@ public class FamilyLianqianController {
                return Result.error(ex.getMessage());
            }
        }
    }
    }*/
}

+ 2 - 3
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/FamilyDao.java

@ -4,7 +4,6 @@ package com.yihu.wlyy.sign.dao;/**
import com.yihu.wlyy.sign.entity.FamilyLianQian;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
@ -13,6 +12,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * @desc 家庭成员
 **/
public interface FamilyDao extends PagingAndSortingRepository<FamilyLianQian, Long>, JpaSpecificationExecutor<FamilyLianQian> {
    @Query("from FamilyLianQian a  where a.idcard = ?1 ")
    FamilyLianQian findByIdCard(String idcard);
   /* @Query("from FamilyLianQian a  where a.idcard = ?1 ")
    FamilyLianQian findByIdCard(String idcard);*/
}

+ 11 - 3
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/entity/FamilyLianQian.java

@ -4,8 +4,6 @@ package com.yihu.wlyy.sign.entity;/**
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@ -18,7 +16,7 @@ import java.io.Serializable;
@Entity
@Table(name = "tbl_lianqian_family")
public class FamilyLianQian extends IdEntity implements Serializable {
    @Column(name = "address_code")
   /* @Column(name = "address_code")
    private String addressCode;//地址
    @Column(name = "relaholder")
    private String relaholder;//关系
@ -32,6 +30,8 @@ public class FamilyLianQian extends IdEntity implements Serializable {
    private String name;//姓名
    @Column(name = "address_name")
    private String addressName;//地址名称
    @Column(name = "address")
    private String address;//地址
    @Column(name = "phone")
    private String phone;//联系方式
    @Column(name = "high_blood_pressure")
@ -189,4 +189,12 @@ public class FamilyLianQian extends IdEntity implements Serializable {
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }*/
}

+ 18 - 15
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/FamilyLianQianService.java

@ -2,20 +2,9 @@ package com.yihu.wlyy.sign.service;/**
 * Created by nature of king on 2018/8/9.
 */
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.sign.dao.*;
import com.yihu.wlyy.sign.entity.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
@ -26,7 +15,7 @@ import java.util.List;
@Service
@Transactional
public class FamilyLianQianService {
    private Logger logger = LoggerFactory.getLogger(FamilyLianQianService.class);
   /* private Logger logger = LoggerFactory.getLogger(FamilyLianQianService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
@ -49,7 +38,7 @@ public class FamilyLianQianService {
        JSONObject object = new JSONObject();
        List<FamilyLianQian> familyLianQians = new ArrayList<>();
        String signSql = "select * from wlyy_sign_family_lianqian WHERE status = "+status+" " +
                "and sign_year= '"+year+"' and hospital_name = '" +hospitalName+"'";
                "and sign_year= '"+year+"' and hospital_name = '" +hospitalName+"' limit 0,100";
        List<SignFamily> signFamilyList = jdbcTemplate.query(signSql,new BeanPropertyRowMapper(SignFamily.class));
        if (signFamilyList != null && signFamilyList.size() != 0){
@ -79,6 +68,7 @@ public class FamilyLianQianService {
                        }else{
                            j=1;
                        }
                        logger.info("residence:"+residenceInfo1.getPersonid());
                        String signSql1 = "select * from wlyy_sign_family_lianqian WHERE status = " + status + " " +
                                "and sign_year= '" + year + "' and idcard = '" + demographicInfo1.getCardid() + "' and hospital_name = '" + hospitalName + "'";
                        List<SignFamily> signFamilyList1 = jdbcTemplate.query(signSql1, new BeanPropertyRowMapper(SignFamily.class));
@ -115,8 +105,21 @@ public class FamilyLianQianService {
                            familyLianQian.setName(demographicInfo1.getName());
                            familyLianQian.setStatus(signFamily1.getStatus().toString());
                            familyDao.save(familyLianQian);
                            ++i;
                        }else{
                            familyLianQian.setName(demographicInfo1.getName());
                            familyLianQian.setStatus("-5");
                            familyLianQian.setSex(Integer.parseInt(demographicInfo1.getSex()));
                            familyLianQian.setIdcard(demographicInfo1.getCardid());
                            FoundationMedicalSystemParam param = tblsysParamDao.findByParamnameAndCode("Relaholder", residenceInfo1.getRelaholder());
                            familyLianQian.setRelaholder(param.getParamchina());
                            familyLianQian.setSignType("0");
                            familyLianQian.setHighBloodPressure(0);
                            familyLianQian.setDiabetes(0);
                            familyLianQian.setBind(0);
                            familyDao.save(familyLianQian);
                        }
                        ++i;
                    }
                    if (i == residenceInfoList.size()&& j==0) {
                        FamilyLianQian familyLianQian = new FamilyLianQian();
@ -132,5 +135,5 @@ public class FamilyLianQianService {
            e.printStackTrace();
            return null;
        }
    }
    }*/
}

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

@ -310,8 +310,8 @@ public class SignRenewZYService {
                                //密码迁移
                                if(patientHad!=null&&!StringUtil.isEmpty(patientHad.getPassword())&&!StringUtil.isEmpty(patientHad.getSalt()))
                                {
                                    patient.setOpenid(patientHad.getPassword());
                                    patient.setOpenid(patientHad.getSalt());
                                    patient.setPassword(patientHad.getPassword());
                                    patient.setSalt(patientHad.getSalt());
                                }
                                else{
                                    //修改旧的默认密码
@ -925,8 +925,8 @@ public class SignRenewZYService {
                                //密码迁移
                                if(patientHad!=null&&!StringUtil.isEmpty(patientHad.getPassword())&&!StringUtil.isEmpty(patientHad.getSalt()))
                                {
                                    patient.setOpenid(patientHad.getPassword());
                                    patient.setOpenid(patientHad.getSalt());
                                    patient.setPassword(patientHad.getPassword());
                                    patient.setSalt(patientHad.getSalt());
                                }
                                else{
                                    //修改旧的默认密码
@ -1116,11 +1116,11 @@ public class SignRenewZYService {
                        needSave = true;
                    }
                    //手机号覆盖
                    /*if(!StringUtil.isEmpty(phoneNumber) && !phoneNumber.equals(patient.getMobile()))
                    if(!StringUtil.isEmpty(phoneNumber) && !phoneNumber.equals(patient.getMobile()))
                    {
                        patient.setMobile(phoneNumber);
                        needSave = true;
                    }*/
                    }
                    if(needSave)
                    {

+ 3 - 2
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -348,9 +348,10 @@ public class PushMsgTask {
            case 5:
                templateId = template_sign_request;
                break;
            case 6:
                //@TODO  以后需要了释放出来 要做易联众对接支付消息
            /*case 6:
                templateId = template_followup_success;
                break;
                break;*/
            case 7:
                templateId = template_treatment_result;
                break;

+ 12 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentMysqlToEsQuotaJob.java

@ -119,6 +119,17 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        this.incrementInterval = map.get("incrementInterval")!=null?String.valueOf(map.get("incrementInterval")):"1";
        //初始化统计年份
        this.year = getNowYearByDate();
        if (StringUtils.isEmpty(endTime)) {
            endTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd") + " 17:00:00"; //2017-06-01 17:00:00
        } else if (endTime.length()==10){
            endTime = endTime + " 17:00:00";
        }
        if("2".equals(incrementInterval)){
            endTime =  DateUtil.getSundayOfThisDate(DateUtil.strToDateLong(endTime));
        }else if("3".equals(incrementInterval)){
            endTime=  DateUtil.getLastDayOfMonth((DateUtil.strToDateLong(endTime)));
        }
        //初始化开始时间
        if ("2".equals(timeLevel)) {
            //按年度到达量
@ -424,7 +435,7 @@ public class CurrentMysqlToEsQuotaJob implements Job {
    public void getStartTime() throws Exception{
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        if("1".equals(this.incrementInterval)){//日
            startTime = new LocalDate(new DateTime().minusDays(2)).toString("yyyy-MM-dd") + " 17:00:00";
            startTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd") + " 17:00:00";
        }else if("2".equals(this.incrementInterval)){//周
            Date monday = DateUtil.getMondayOfThisDayToDate(sf.parse(endTime));
//            startTime =sf.format(monday)+ " 17:00:00";

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

@ -2,7 +2,6 @@ package com.yihu.wlyy.activemq;
import com.yihu.es.entity.HealthEduArticleES;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
@ -23,7 +22,10 @@ import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
 * Created by chenweida on 2017/9/9.
@ -169,6 +171,7 @@ public class HealthArtListener implements MessageListener {
                        json.put("toUser", member.getCode());
                        json.remove("first");
                        json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
//                        json.put("represented","");
                        if (StringUtils.isNotBlank(member.getOpenid())) {
                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9, member.getOpenid(), patient.getName(), json);
                        }

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

@ -282,6 +282,16 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("NoticeJob  job exist");
            }
            //获取儿童可预约疫苗,每天凌晨1点执行一次
            if (!quartzHelper.isExistJob("child_immune_vaccin_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("child_immune_vaccin_job");
                quartzHelper.addJob(ChildImmuneVaccinJob.class, trigger, "child_immune_vaccin_job", new HashMap<String, Object>());
                logger.info("child_immune_vaccin_job  job success");
            } else {
                logger.info("child_immune_vaccin_job  job exist");
            }
        } catch (Exception e) {
            logger.info("sign end job start failed");
        }

+ 28 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/ChildImmuneVaccinJob.java

@ -0,0 +1,28 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.imm.ChildVaccinImmuneService;
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;
public class ChildImmuneVaccinJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(ChildImmuneVaccinJob.class);
    @Autowired
    private ChildVaccinImmuneService childVaccinImmuneService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("START========每天获取儿童可预约疫苗JOB========");
        try {
            childVaccinImmuneService.getChildImmuneVaccinEveryDay();
            logger.info("END========每天获取儿童可预约疫苗JOB========");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("END===ERROE===每天获取儿童可预约疫苗JOB,message:"+e.getMessage());
        }
    }
}

+ 21 - 21
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/FollowUpSynJob.java

@ -28,26 +28,26 @@ public class FollowUpSynJob implements Job {
	
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
//		logger.info("START=====居民随访记录同步JOB");
//		try {
//
//			Date end = new Date();
//			do{
//				String startTime =  systemDictService.getFollowupSynTime();   //上次执行时间
//				logger.info("采集时间:start="+startTime);
//				end = DateUtil.getNextMin(DateUtil.strToDate(startTime), 20);
//				String endTime = DateUtil.dateToStrLong(end);//采集20分钟后的数据
//				logger.info("采集时间:end="+endTime);
//				//根据起止时间查询家签居民随访记录,并同步到本地数据库
//				jwPrescriptionService.getFollowUpByTime(startTime,endTime);
//				//更新下次采集签约时间
//				systemDictService.saveFollowupSynTime(endTime);
//
//			}while (end.before(new Date()));
//			logger.info("END========居民随访记录同步JOB");
//		}catch (Exception e){
//			e.printStackTrace();
//			logger.info("END===ERROE===居民随访记录同步JOB,message:"+e.getMessage());
//		}
		logger.info("START=====居民随访记录同步JOB");
		try {
			Date end = new Date();
			do{
				String startTime =  systemDictService.getFollowupSynTime();   //上次执行时间
				logger.info("采集时间:start="+startTime);
				end = DateUtil.getNextMin(DateUtil.strToDate(startTime), 5);
				String endTime = DateUtil.dateToStrLong(end);//采集20分钟后的数据
				logger.info("采集时间:end="+endTime);
				//根据起止时间查询家签居民随访记录,并同步到本地数据库
				jwPrescriptionService.getFollowUpByTime(startTime,endTime);
				//更新下次采集签约时间
				systemDictService.saveFollowupSynTime(endTime);
			}while (end.before(new Date()));
			logger.info("END========居民随访记录同步JOB");
		}catch (Exception e){
			e.printStackTrace();
			logger.info("END===ERROE===居民随访记录同步JOB,message:"+e.getMessage());
		}
	}
}

+ 31 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java

@ -0,0 +1,31 @@
package com.yihu.wlyy.repository.imm;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author zhangdan
 * @date 2018/9/27 09:38
 */
public interface ChildImmuneVaccinDao extends PagingAndSortingRepository<ChildImmuneVaccin, Long>,
		JpaSpecificationExecutor<ChildImmuneVaccin> {
	List<ChildImmuneVaccin> findByBarcode(String barcode);
	@Modifying
	@Query("update ChildImmuneVaccin  c set c.del=1 where c.code=?1")
	int updateDelByCode(String code);
	@Modifying
	@Query("update ChildImmuneVaccin  c set c.isOut=0 where c.code=?1")
	int updateIsOutByCode(String code);
	@Modifying
	@Query("update ChildImmuneVaccin  c set c.alert_tag=0 where c.code=?1")
	int updateAlertTagByCode(String code);
}

+ 167 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/imm/ChildVaccinImmuneService.java

@ -0,0 +1,167 @@
package com.yihu.wlyy.service.imm;
import com.yihu.wlyy.entity.imm.ChildFamilyImmune;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import com.yihu.wlyy.entity.imm.ChildInfo;
import com.yihu.wlyy.repository.imm.ChildImmuneVaccinDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.ImmuneService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
 * 免疫关系业务层
 * @author zhangdan
 * @date 2018/9/27 20:01
 */
@Service
public class ChildVaccinImmuneService extends BaseService {
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private ChildImmuneVaccinDao childImmuneVaccinDao;
	@Autowired
	private ImmuneService immuneService;
	
	@Transactional(rollbackFor = Exception.class)
	public int getChildImmuneVaccinEveryDay()throws Exception{
		int result = 0;
		try {
			String sql ="SELECT" +
					" DISTINCT ci.`code`," +
					" ci.idcard," +
					" ci.`name`," +
					" ci.ssc," +
					" ci.barcode" +
					" FROM" +
					" wlyy_child_family_immune fi" +
					" LEFT JOIN wlyy_child_info ci ON fi.child_code = ci.`code`" +
					" WHERE" +
					" fi.del = 0";
			List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
			for (Map<String,Object> map : list){
				String barcode = String.valueOf(map.get("barcode"));
				System.out.println("===============barcode=============="+barcode);
				String deptStr = immuneService.findDept(barcode);
				if (StringUtils.isNotBlank(deptStr)){
					JSONObject jsonObject = new JSONObject(deptStr);
					if (jsonObject.getInt("status")==200) {
						JSONObject json = new JSONObject(jsonObject.getString("data"));
						JSONArray jsonArray = json.getJSONArray("body");
						for (int i = 0;i<jsonArray.length();i++){
							String deptNum  = jsonArray.getJSONObject(i).getString("deptNum");
							String vaccinStr = immuneService.findMyVaccin(barcode,deptNum);
							JSONObject vaccinJson = new JSONObject(vaccinStr);
							if (vaccinJson.getInt("status")==200) {
								JSONObject vaccinJson2 = new JSONObject(vaccinJson.getString("data"));
								JSONArray vaccinJsonJSONArray = vaccinJson2.getJSONArray("body");
								List<ChildImmuneVaccin> vaccinList = childImmuneVaccinDao.findByBarcode(barcode);
								//原来有的则不用新增,原来有的但是在返回回来的数据没有的话删除数据
								for (ChildImmuneVaccin childImmuneVaccin : vaccinList){
									int count = 0;
									for (int j=0;j<vaccinJsonJSONArray.length();j++){
										String ymbm = vaccinJsonJSONArray.getJSONObject(j).getString("ymBm");
										String jzzc = vaccinJsonJSONArray.getJSONObject(j).getString("jzZc");
										if (childImmuneVaccin.getYmbm().equals(ymbm) && childImmuneVaccin.getJzzc().equals(jzzc)){
											count++;
										}
									}
									//原来有的疫苗要判断是否有超过预约时间的7天,并且看提醒是否超过7天,超过7天可以重新提醒
									if (count>0 && childImmuneVaccin.getIsOut()==1){
										if (DateUtil.getPreDays(childImmuneVaccin.getJzrq(),7).before(new Date())){
											//过了预约时间7天,更新为isOut=0,则不能预约了
											//childImmuneVaccinDao.updateIsOutByCode(childImmuneVaccin.getCode());
											String uSql ="UPDATE wlyy_child_immune_vaccin SET is_out=0  AND `code`='"+childImmuneVaccin.getCode()+"'";
											jdbcTemplate.update(uSql);
										}else {
											//判断是否过了7天提醒时间
											if (childImmuneVaccin.getAlert_tag()==1 && DateUtil.getPreDays(childImmuneVaccin.getAlert_time(),7).before(new Date())) {
												String updateSql = "UPDATE wlyy_child_immune_vaccin SET alert_tag=0  AND `code`='" + childImmuneVaccin.getCode() + "'";
												jdbcTemplate.update(updateSql);
											}
										}
									}
									if (count==0){
										result+= childImmuneVaccinDao.updateDelByCode(childImmuneVaccin.getCode());
									}
								}
								//如果本地没有就是新增的
								List<ChildImmuneVaccin> vaccins = new ArrayList<>();
								for (int j=0;j<vaccinJsonJSONArray.length();j++){
									String ymbm = vaccinJsonJSONArray.getJSONObject(j).getString("ymBm");
									String jzzc = vaccinJsonJSONArray.getJSONObject(j).getString("jzZc");
									int count = 0;
									for (ChildImmuneVaccin childImmuneVaccin : vaccinList){
										if (childImmuneVaccin.getYmbm().equals(ymbm) && childImmuneVaccin.getJzzc().equals(jzzc)){
											count++;
										}
									}
									if (count==0){
										ChildImmuneVaccin childImmuneVaccin = new ChildImmuneVaccin();
										childImmuneVaccin.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
										childImmuneVaccin.setName(String.valueOf(map.get("name")));
										childImmuneVaccin.setIdcard(String.valueOf(map.get("idcard")));
										childImmuneVaccin.setSsc(String.valueOf(map.get("ssc")));
										childImmuneVaccin.setBarcode(barcode);
										childImmuneVaccin.setChildInfoCode(String.valueOf(map.get("code")));
										childImmuneVaccin.setYmkc(vaccinJsonJSONArray.getJSONObject(j).getString("ymkc"));
										childImmuneVaccin.setYmmc(vaccinJsonJSONArray.getJSONObject(j).getString("ymmc"));
										childImmuneVaccin.setYmkcsm(vaccinJsonJSONArray.getJSONObject(j).getString("ymkcsm"));
										childImmuneVaccin.setYmbm(ymbm);
										childImmuneVaccin.setJzzc(jzzc);
										childImmuneVaccin.setJzrq(DateUtil.strToDate(vaccinJsonJSONArray.getJSONObject(j).getString("jzRq"),DateUtil.YYYY_MM_DD));
										childImmuneVaccin.setAlert_tag(0);
										childImmuneVaccin.setDel(0);
										childImmuneVaccin.setCreate_time(new Date());
										if (DateUtil.getPreDays(DateUtil.strToDate(vaccinJsonJSONArray.getJSONObject(j).getString("jzRq")),7).before(new Date())){
											//过了预约时间7天,更新为isOut=0,则不能预约了
											childImmuneVaccin.setIsOut(0);
										}else {
											childImmuneVaccin.setIsOut(1);
										}
										vaccins.add(childImmuneVaccin);
										result++;
									}
								}
								childImmuneVaccinDao.save(vaccins);
							/*for (int j=0;j<vaccinJsonJSONArray.length();j++){
								String ymbm = vaccinJsonJSONArray.getJSONObject(j).getString("ymBm");
								String jzzc = vaccinJsonJSONArray.getJSONObject(j).getString("jzZc");
								if (childImmuneVaccinDao.findByBarcodeAndYmbmAndJzzc(barcode,ymbm,jzzc)==null){
									ChildImmuneVaccin childImmuneVaccin = new ChildImmuneVaccin();
									childImmuneVaccin.setCode(getUUID());
									childImmuneVaccin.setName(String.valueOf(map.get("name")));
									childImmuneVaccin.setIdcard(String.valueOf(map.get("idcard")));
									childImmuneVaccin.setSsc(String.valueOf(map.get("ssc")));
									childImmuneVaccin.setBarcode(barcode);
									childImmuneVaccin.setYmkc(vaccinJsonJSONArray.getJSONObject(j).getString("ymkc"));
									childImmuneVaccin.setYmmc(vaccinJsonJSONArray.getJSONObject(j).getString("ymmc"));
									childImmuneVaccin.setYmkcsm(vaccinJsonJSONArray.getJSONObject(j).getString("ymkcsm"));
									childImmuneVaccin.setYmbm(ymbm);
									childImmuneVaccin.setJzzc(jzzc);
									childImmuneVaccin.setAlert_tag(0);
									childImmuneVaccin.setCreate_time(new Date());
								}
							}*/
							}
						}
					}
				}
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return result;
	}
}

+ 56 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/ImmuneService.java

@ -0,0 +1,56 @@
package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
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.text.SimpleDateFormat;
import java.util.*;
/**
 * 免疫接种预约挂号
 * @author zhangdan
 * @date 2018/9/27 19:43
 */
@Service
public class ImmuneService {
	private static final Logger logger = LoggerFactory.getLogger(ImmuneService.class);
	//基卫服务地址
	@Value("${sign.check_upload}")
	private String jwUrl;
	@Autowired
	private HttpClientUtil httpClientUtil;
	public String findMyVaccin(String barcode,String deptNum) throws Exception{
		String url = jwUrl + "/third/jm/imm/findMyVaccin";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("deptNum", deptNum));
		params.add(new BasicNameValuePair("etmykh", barcode));
		String response = httpClientUtil.post(url, params, "UTF-8");
		return response;
	}
	public String findDept(String barcode) throws Exception{
		String url = jwUrl + "/third/jm/imm/findDept";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("etmykh", barcode));
		String response = httpClientUtil.post(url, params, "UTF-8");
		return response;
	}
}

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

@ -291,9 +291,9 @@ public class PushMsgTask {
            String temp_id = "";
            if (type == 3) {
                if (json.has("isPublic") && json.getInt("isPublic") == 1) {
                    temp.setUrl(url + "jbsq/html/public-consult-detail.html?openid=" + openid + "&code=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(url + "jbsq/html/public-consult-detail.html?openid=" + openid + "&code=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                } else {
                    temp.setUrl(url + "yszx/html/consulting-doctor.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(url + "yszx/html/consulting-doctor.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                }
                temp_id = template_consult_notice;
                temp.setTemplate_id(temp_id);
@ -328,10 +328,10 @@ public class PushMsgTask {
                } else {
                    if (json.has("agent") && ("1".equals(json.getString("agent")))) {
//                        发送给授权代理人
                        temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + json.getString("represented") + "&signCode=" + json.getString("signCode"));
                        temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):"") + "&signCode=" + json.getString("signCode"));
                    } else if (json.has("agent") && ("0".equals(json.getString("agent")))) {
//                        发送给自己
                        temp.setUrl(url + "qygl/html/pay_flow.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + json.getString("represented") + "&signCode=" + json.getString("signCode"));
                        temp.setUrl(url + "qygl/html/pay_flow.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):"") + "&signCode=" + json.getString("signCode"));
                    }
                }
                temp.setTouser(openid);
@ -354,7 +354,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("content"));
                m.put("keyword4", keyword4);
            } else if (type == 4) {
                temp.setUrl(url + "yszd/html/guidance-detail.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&id=" + String.valueOf(json.get("id")) + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "yszd/html/guidance-detail.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&id=" + String.valueOf(json.get("id")) + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_health_notice;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -378,7 +378,7 @@ public class PushMsgTask {
                keyword5.setValue(json.getString("content"));
                m.put("keyword5", keyword5);
            } else if (type == 5) {
                temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_termination;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -398,7 +398,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("date"));
                m.put("keyword4", keyword4);
            } else if (type == 6) {
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid + "&orgCode=" + json.get("orgCode") + "&id=" + json.getString("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid + "&orgCode=" + json.get("orgCode") + "&id=" + json.getString("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_appoint_success;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -418,7 +418,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("date"));
                m.put("planstarttime", keyword4);
            } else if (type == 7) {
                temp.setUrl(url + "wdyy/html/my-appointment.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "wdyy/html/my-appointment.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_appoint_failed;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -458,11 +458,11 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("content"));
                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"));
                temp.setUrl(url + "jkjy/html/article.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                //如果是ArticleUrl不为空,那就说明是外部系统推送文章(如:集美宣教)
                Boolean articleUrl = json.has("newArricleFlag") ? json.getBoolean("newArricleFlag") : false;
                if(articleUrl.booleanValue()){
                    temp.setUrl(url + "jkjy/html/article2.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(url + "jkjy/html/article2.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                }
                temp_id = template_healthy_article;
                temp.setTemplate_id(temp_id);
@ -490,7 +490,7 @@ public class PushMsgTask {
                if (json.has("url")) {
                    temp.setUrl(url + json.getString("url"));
                }else {
                    temp.setUrl(url + "qygl/html/signing-doctors.html?openid=" + openid + "&state=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(url + "qygl/html/signing-doctors.html?openid=" + openid + "&state=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                }
                temp.setTemplate_id(template_doctor_change);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -511,7 +511,7 @@ public class PushMsgTask {
                if (json.has("url")) {
                    temp.setUrl(url + json.getString("url"));
                } else {
                    String xinurl = url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&survey_id=" + json.getString("survey_id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented");
                    String xinurl = url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&survey_id=" + json.getString("survey_id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):"");
//                temp.setUrl(url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&survey_id=" + json.getString("survey_id") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                    temp.setUrl(xinurl);
                }
@ -594,7 +594,7 @@ public class PushMsgTask {
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
            } else if (type == 16) {
                temp.setUrl(url + "xuqian/html/information.html?openid=" + openid + "&changeDoctor=" + 1 + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "xuqian/html/information.html?openid=" + openid + "&changeDoctor=" + 1 + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp.setTemplate_id(template_doctor_survey);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
@ -605,7 +605,7 @@ public class PushMsgTask {
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            } else if (type == 17) {
                temp.setUrl(url + "yszx/html/manyidu.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "yszx/html/manyidu.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp.setTemplate_id(template_doctor_survey);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");

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

@ -89,6 +89,7 @@ images:
sign:
  check_upload: http://172.19.103.88:8011/wlyy_service
  zysoft: http://59.61.92.90:8072/wlyy_sign
  #check_upload: http://localhost:8011/
quartz:
  name: schedulerFactoryBean_test_dev

+ 14 - 14
patient-co/patient-co-wlyy-job/src/main/resources/application-test.yml

@ -43,35 +43,35 @@ wechat:
  accId: gh_ffd64560fb21
  message:
   ##医生追加建议提醒 --签约邀请
   doctor_invitel_template: uXdBJVbrhKG-WLaCG4s8C4SXSr2kknQ94vKFt-3rIiA
   doctor_invitel_template: YA8VtN_JYORLHrbEhQkNoRjlpJXIGVGnb4_OhVq4OBs
   #咨询回复
   template_consult_notice: dr4QNyFoRvVsf8uWxXMC1dRyjwnbUuJwJ21vBLhf18
   template_consult_notice: oGFfTWPEYvwwfmcIK1hquZ4-cVXdNomV3bCMLfj97Jc
   #签约成功
   template_sign_success: VYGj8OUKj6FH4i4_nZS2UAHurJxQHx-7_OBPILIdB8s
   template_sign_success: SQBxvSvX_JA5xez11MIFvxzamV0w3i3DeU8yB8O1lUY
   #签约失败
   template_sign_failed: m221Jrkm0UUY00ExTCpQNTB8t_1U_V4LR9Bg8BgH9-o
   template_sign_failed: sFyAMmdJjzeqjzQvRcjIajDtUZx3pBhTGxRyj-A-uuQ
   #健康指导提醒
   template_health_notice: 5Nts8lA_at9Cd1JuTK-qDxx95lchpcmUfPTEwYDgXYQ
   template_health_notice: hOu3swzpEi07jY5ojEB1vd6M6pflksn3pgfAQ6R6NT0
   #解约提醒
   template_termination:  qZm1NwSueAsbHaOf9DrnLoSj0X5gZuh9W7aDYzLWNds
   template_termination:  K1rUqmIJ6RvQviit1r_ZyPCRmjdZyFZVe0_zKeVWu30
   #预约成功
   template_appoint_success:  vU5x2tGyk1zUngBrEqMfnFqqMa6M8J98w8k5MCSUYM
   template_appoint_success:  3JNK8saVZvWUTWZ1veamC_pAEJPOLorj0sRKv1_V6-Y
   #预约取消
   template_appoint_failed:  r-bVEKgXVyl8O96saoJXlLd7DX1zW7fXA4a0PZHxiQM
   template_appoint_failed:  iq9An2I_WgUC2BnouzSpL0bDflAO6B_AQw5TjTrYKgU
   #缴费提醒
   template_expenses_remind:  pZby4Mz3H5angmjGTuvXzo9lwlaVfEiqORwI8soI-5E
   template_expenses_remind:  umuDSVNrUy_yYPmENRg1BHszW3sDpFtCCPEdobXxAmQ
   #健康教育
   template_healthy_article: aO_qqk5nAXaGXhsikPVLNelqzwlrp1LTPfIQ1qRMpxo
   template_healthy_article: dH8ML1nDOruIAUnA9dv19w4HF95p_xiHcmpq-Noutxo
   #医生变更
   template_doctor_change:  V5h0F84t972kUzQvWy8qYrgdaYGJVj10pFeFVl19Nb8
   template_doctor_change:  RMKwJ-PLHP-uBwjJlHDgPaVFZhjuXvhSO7V8Dwh7vPc
   #问卷调查
   template_doctor_survey:  OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4
   #审核结果通知
   template_doctor_audit:  lCtOgJgL1tBJbAytqN7cn-FgCH_Usg99FENEy2TrC08
   template_doctor_audit:  kyrkan8cWQ22J_NC01e8yGwsn75MeUtfgdCrZKkwSLQ
   #服务结果通知
   template_doctor_service:  i34rq3xFLnpf_VN2Jor9n2YlQqJMM7oXyYvuctriISw
   template_doctor_service:  2hEhp2bLfmM-7Goc6rJ3EE4a4wvuhyndKufruYTk6A0
   #设备测量提醒
   template_device_measure_notice: bzwLOFFPSe2vq74IljvVIPmvjP-C4ebEUAFORyq-2dY
   template_device_measure_notice: 5bzC6o_9zlL24loYnF7hFLskuRzCyX8v48KfWmYOL3c
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/

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

@ -137,6 +137,9 @@ patient_confirm_receipt_job=00 0 8,12,18,21 * * ?
# 病患者医疗保险号同步JOB (每天6点执行一次)
patient_medicare_number_job=0 0 6 * * ?
# 获取儿童可预约疫苗,每天凌晨1点执行一次
child_immune_vaccin_job=0 0 1 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html
#统一支付平台支付接口地址

+ 43 - 0
patient-co/patient-co-wlyy/doc/技术文档/es/可预约疫苗提醒日志新增索引

@ -0,0 +1,43 @@
创建索引
POST  http://172.19.103.68:9200/wlyy_patient_remind_record
查询索引
GET http://172.19.103.68:9200/wlyy_patient_remind_record/
给索引加mapping
POST http://172.19.103.68:9200/wlyy_patient_remind_record/wlyy_patient_remind_record/_mapping
{
    "wlyy_patient_remind_record": {
            "properties": {
				"code": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "patient": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "patientName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "doctor": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "doctorName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "remindType": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "status": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "createTime": {
                    "type": "date"
                }
            }
        }
  }

+ 4 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -23,7 +23,7 @@ import java.lang.reflect.Method;
import java.util.Date;
/**
 * 患者权限校验
 * 患者权限校验.
 *
 * @author George
 */
@ -81,7 +81,9 @@ public class PatientInterceptor extends BaseInterceptor {
                token = tokenDao.findByPatient(user, platform);
                // 加入缓存
                if (platform == 3) {
                    systemDataRedis.setPatientToken(token);
                    if(token!=null){
                        systemDataRedis.setPatientToken(token);
                    }
                    //SystemData.patientTokens.put(user, token);
                }
            }

+ 10 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyQuestionResultDao.java

@ -0,0 +1,10 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyQuestionResult;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by humingfen on 2018/9/29.
 */
public interface SurveyQuestionResultDao extends PagingAndSortingRepository<SurveyQuestionResult, Long> {
}

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

@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -25,7 +24,7 @@ public interface SurveyTemplatesDao extends PagingAndSortingRepository<SurveyTem
    @Query("select count(t.id)  from SurveyTemplates t where t.title like ?1 ")
    int distinctLikeTitle(String title);
    @Query("select  t from SurveyTemplates t where t.code = ?1 ")
    @Query("select  t from SurveyTemplates t where t.code = ?1 and t.del = 1")
    SurveyTemplates findById(String code);
    @Modifying

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildFamilyImmuneDao.java

@ -19,4 +19,6 @@ public interface ChildFamilyImmuneDao extends PagingAndSortingRepository<ChildFa
	
	@Query("select p from ChildFamilyImmune p where p.childCode = ?1 and p.familyCode = ?2 and p.del = 0")
	ChildFamilyImmune findByfaAndChildCodeAndFamilyCode(String childcode,String familycode);
	List<ChildFamilyImmune> findByChildCode(String childCode);
}

+ 20 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java

@ -2,9 +2,12 @@ package com.yihu.wlyy.repository.imm;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author huangwenjie
 * @date 2018/6/21 09:38
@ -12,5 +15,21 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface ChildImmuneVaccinDao extends PagingAndSortingRepository<ChildImmuneVaccin, Long>,
		JpaSpecificationExecutor<ChildImmuneVaccin> {
	@Query("select p from ChildImmuneVaccin p where p.barcode=?1")
	ChildImmuneVaccin getChildImmuneVaccinByBarcode(String barcode);
	List<ChildImmuneVaccin> getChildImmuneVaccinByBarcode(String barcode);
	List<ChildImmuneVaccin> findByBarcodeAndYmbmAndJzzc(String barcode,String ymbm,String jzzc);
	List<ChildImmuneVaccin> findByBarcode(String barcode);
	@Modifying
	@Query("update ChildImmuneVaccin  c set c.del=1 where c.code=?1")
	int updateDelByCode(String code);
	@Modifying
	@Query("update ChildImmuneVaccin  c set c.isOut=0 where c.code=?1")
	int updateIsOutByCode(String code);
	@Modifying
	@Query("update ChildImmuneVaccin  c set c.alert_tag=?2 where c.code=?1")
	int updateAlertTagByCode(String code,int tag);
}

+ 14 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -60,13 +60,13 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("update Message a set a.read = 0 where a.receiver = ?1 and a.sender=?2 and a.tzType=?3")
    int updateHealthIndexMessageByPatient(String doctor, String patient, String type);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,16,17,18,19,20,21,22,23) order by a.czrq desc")
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,16,17,18,19,20,21,22,23,24,25,26,27) order by a.czrq desc")
    List<Message> getSystemMessageUnread(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type in (6,7) order by a.createTime desc")
    List<Message> getSysTemMessageByPrescription(String doctor, String prescriptionStatus);
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,301,16,17,18,19,20,21,22,23) and (a.del = '1' or a.del is null) ")
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,301,16,17,18,19,20,21,22,23,24,25,26,27) and (a.del = '1' or a.del is null) ")
    List<Message> getSystemMessage(String doctor, Pageable pageRequest);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.prescriptionStatus='0' ")
@ -169,4 +169,16 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("update Message a set a.read = 0 where a.id = ?1")
    @Modifying
    int setSpecialistReadById(Long id);
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type in (24,25,26,27) order by a.czrq desc")
    List<Message> getSynergyService(String receiver);
    @Query("select a from Message a where  a.receiver = ?1 and a.state = 1 and a.type in (24,25,26,27) order by a.czrq desc")
    List<Message> getSynergyMessages(String receiver,Pageable pageable);
    @Query("update Message a set a.read = 0 where a.receiver = ?1 and a.type in (24,25,26,27)")
    @Modifying
    int setSynergyMessagesByRead(String doctor);
}

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

@ -1322,13 +1322,14 @@ public class DoctorInfoService extends BaseService {
                        json.remove("toUser");
                        json.put("toUser", member.getCode());
                        json.remove("first");
                        json.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) json.get("relation"), p.getName()) + p.getName() + ",您好!您签约团队的全科医生已变更,您的新全科医生信息如下:");
                        json.put("first", weiXinOpenIdUtils.getTitleMes(p, 0, p.getName()) + p.getName() + ",您好!您签约团队的全科医生已变更,您的新全科医生信息如下:");
                        pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 10, member.getOpenid(), p.getName(), json);
                    }
                }
            }
        }catch (Exception e){
            logger.info(e.getMessage());
            e.printStackTrace();
        }
    }

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

@ -146,7 +146,7 @@ public class FamilyMemberService extends BaseService {
            fm.setFamilyMember(member);
        }
        fm.setFamilyRelation(relation);
        fm.setIsAuthorize(1);//默认授权
        fm.setIsAuthorize(0);//默认授权
        fm.setCzrq(new Date());
        // 添加对方与自己的关系
@ -357,6 +357,7 @@ public class FamilyMemberService extends BaseService {
            result.put("name", StringUtils.isEmpty(p.getName()) ? "" : p.getName());
            result.put("code", StringUtils.isEmpty(p.getCode()) ? "" : p.getCode());
            result.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
            result.put("sex",p.getSex());
        }
        return result;
@ -804,8 +805,6 @@ public class FamilyMemberService extends BaseService {
        switch (relation) {
            case 1:
                relationTrans = 1;
                break;
            case 2:
                if (patient.getSex() == 1) {
                    relationTrans = 5;
@ -954,7 +953,7 @@ public class FamilyMemberService extends BaseService {
    }
    public String getFamilyMesListSql(String code) {
        StringBuffer sql = new StringBuffer("SELECT t.*,p.idcard,p.mobile,p.photo FROM wlyy_patient_family_temp t,wlyy_patient p WHERE t.patient = p.code AND t.dealer ='" + code+"'");
        StringBuffer sql = new StringBuffer("SELECT t.*,p.idcard,p.mobile,p.photo,p.sex FROM wlyy_patient_family_temp t,wlyy_patient p WHERE t.patient = p.code AND t.dealer ='" + code+"'");
        return sql.toString();
    }
@ -1151,7 +1150,7 @@ public class FamilyMemberService extends BaseService {
        }
        fm.setFamilyRelation(relation);
        fm.setCzrq(new Date());
        fm.setIsAuthorize(1);//默认授权
        fm.setIsAuthorize(0);//默认授权
        // 添加对方与自己的关系
        PatientFamilyMember fmt = memberDao.findByPatientAndFamilyMember(member, patient);
@ -1167,7 +1166,7 @@ public class FamilyMemberService extends BaseService {
        int relationTrans = familyRelationTrans(p, relation);
        fmt.setFamilyRelation(relationTrans);
        fmt.setCzrq(new Date());
        fmt.setIsAuthorize(1);//默认授权
        fmt.setIsAuthorize(0);//默认授权
        memberDao.save(fm);
        memberDao.save(fmt);

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

@ -177,7 +177,7 @@ public class PatientHealthGuidanceService extends BaseService {
		if(StringUtils.isNotEmpty(tzCode)&&!"undefined".equals(tzCode)){
			String sql = " select * from device.wlyy_patient_health_index where id in ("+tzCode+")";
			List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
			long h24 = 60*60*60*24+10;
			long h24 = 1000*60*60*24+10;
			for(Map<String, Object> one :list){
				if(one.get("manage_result")!=null&&((Integer)one.get("manage_result")==1||(Integer)one.get("manage_result")==2))continue;
				String tempSql="";

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/CreditLogService.java

@ -119,7 +119,7 @@ public class CreditLogService {
        object.put("filter",patientIds.toArray());
        object.put("page",page);
        object.put("size",size);
        String url = getBaseUrl() + "selectByRanking";
        String url = /*getBaseUrl()*/"http://localhost:10051/svr-health-bank/" + "selectByRanking";
        String response = null;
        JSONArray data =null;
        JSONObject object1 = null;
@ -288,7 +288,7 @@ public class CreditLogService {
        object.put("name",patient.getName());
        object.put("idCard",patient.getIdcard());
        String response = null;
        String url =getBaseUrl() + "selectAccount";
        String url =/*getBaseUrl()*/"http://localhost:10051/svr-health-bank/" + "selectAccount";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        try {

+ 44 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -279,6 +279,20 @@ public class MessageService extends BaseService {
            specialistMesJson.put("amount", 0);
        }
        List<Message> synergyList = new ArrayList<>();
        synergyList = messageDao.getSynergyService(doctor);
        JSONObject synergyMesJson = new JSONObject();
        if (synergyList != null && synergyList.size() > 0) {
            synergyMesJson.put("amount", synergyList.size());
            JSONObject  synergyJson = new JSONObject();
            synergyJson.put("title", synergyList.get(0).getTitle());
            synergyJson.put("type", synergyList.get(0).getType());
            synergyJson.put("msg", "您有"+synergyList.size()+"个专科服务消息,请查看!");
            synergyJson.put("msgTime", DateUtil.dateToStrLong(synergyList.get(0).getCreateTime()));
            synergyMesJson.put("lastMessage", synergyJson);
        }else{
            synergyMesJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
@ -291,6 +305,7 @@ public class MessageService extends BaseService {
        json.put("deviceUnbind",deviceMesJson);//设备解绑消息
        json.put("familyList",familyMesJson);//居民签约申请
        json.put("specialistList",specialistMesJson);//专科服务消息
        json.put("synergyList",synergyMesJson);//协同服务消息
        return json;
    }
@ -1055,4 +1070,33 @@ public class MessageService extends BaseService {
        }
    }
    /**
     * 获取协同服务消息
     *
     * @param message
     * @param page
     * @param size
     * @return
     * @throws Exception
     */
    public List<Message> getSynergyMessages(Message message, Integer page, Integer size) throws Exception{
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC,"createTime");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, size, sort);
        return messageDao.getSynergyMessages(message.getReceiver(),pageRequest);
    }
    /**
     * 设置协同消息一键已读
     *
     * @param doctor
     * @return
     */
    public Integer setSynergyMessagesByRead(String doctor) {
      return   messageDao.setSynergyMessagesByRead(doctor);
    }
}

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

@ -2635,15 +2635,17 @@ public class FamilyContractService extends BaseService {
                //发送代理人
                JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
                if (jsonArray != null && jsonArray.length() > 0) {
                    String msgFirst = (String)msg.get("first");
                    for (int i = 0; i < jsonArray.length(); i++) {
                        JSONObject j = jsonArray.getJSONObject(i);
                        Patient member = (Patient) j.get("member");
                        JSONObject data = msg;
                        data.remove("toUser");
                        data.put("toUser", member.getCode());
                        String first = (String) data.get("first");
                        String first = msgFirst;
                        data.remove("first");
                        data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()));
                        data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName())+first);
//                        data.put("represented","");
                        pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 10, member.getOpenid(), p.getName(), data);
                    }
                }

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

@ -5623,18 +5623,17 @@ public class StatisticsESService {
                    if (hos.getCode().length() > 10) {
                        continue;
                    }
//                    String sql = " select count(DISTINCT p.doctor,p.device_sn) AS amount,p.doctor as doctorCode,r.name as doctorName from wlyy.wlyy_patient_device p JOIN wlyy.wlyy_doctor r on p.doctor is not null and  p.doctor =r.code  LEFT JOIN device.wlyy_devices d on p.device_sn=d.device_code where p.del=0 and p.doctor is not null and d.grant_org_code ='" + hos.getCode() + "'  group by p.doctor,r.name";
                    String sql = " select count(*) as amount,if(a.doctor is null,'other',a.doctor) as doctorCode,if(a.NAME is null,'其他',a.NAME) as doctorName " +
                            " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p RIGHT join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                            "where p.del=0 and d.is_binding in (1,2) and p.category_code in('1','2') and d.grant_org_code ='" + hos.getCode() + "') a " +
                            " GROUP BY a.doctor,a.name";
                    //计算发放量,按发放人分组
                    String sql =" select count(*) as amount, if(d.grant_doctor is null,'other',d.grant_doctor) as doctorCode,if(d.grant_doctor_name is null,'其他',d.grant_doctor_name) as doctorName from device.wlyy_devices d " +
                            " LEFT JOIN dm_device dd ON d.device_model = dd.model" +
                            " where dd.category_code IN('1','2') and d.grant_org_code = '"+ hos.getCode()+"' and d.grant_admin_team NOT IN(SELECT id FROM wlyy_admin_team WHERE LENGTH(org_code)!=10) GROUP BY d.grant_doctor,d.grant_doctor_name";
                    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                    for (Map<String, Object> one : list) {
                        Map<String, Object> obj = new HashMap<>();
                        obj.put("code", one.get("doctorCode"));
                        obj.put("name", one.get("doctorName"));
                        obj.put("amount", one.get("amount"));
                        obj = deviceRateList(obj,hos);
                        obj = deviceRateList(obj,hos);//统计每个人发放的设备中绑定的数量
                        if("other".equals(one.get("doctorCode")+"")){
                            amount += Integer.valueOf(obj.get("amount")+"");
                            allNum += Integer.valueOf(obj.get("allNum")+"");
@ -5767,21 +5766,18 @@ public class StatisticsESService {
    //按绑定的医生列表展示绑定的设备列表
    public Map<String, Object> deviceRateList(Map<String, Object> reMap,Hospital hos){
//        String sql = " select count(1) as amount from wlyy.wlyy_patient_device p JOIN wlyy.wlyy_doctor r on p.doctor is not null and  p.doctor =r.code  LEFT JOIN device.wlyy_devices d on p.device_sn=d.device_code where  p.doctor is not null and d.grant_org_code ='" + hos.getCode() + "' and p.doctor='"+reMap.get("code")+"'";
        String temp = "other".equals(reMap.get("code"))? " and wd.grant_org_code ='"+hos.getCode()+"' and (wd.grant_doctor is null or wd.grant_doctor='')":" and wd.grant_doctor='"+String.valueOf(reMap.get("code"))+"' ";
       /* String sql = " select count(1) as amount " +
                " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p left join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                " where d.is_binding in (1,2) and p.category_code in('1','2') and d.grant_org_code ='" + hos.getCode() + "' "+temp+") a " +
                " GROUP BY a.doctor,a.name";*/
       String sql ="SELECT count(1) as amount from device.wlyy_devices wd LEFT JOIN dm_device dd ON wd.device_model=dd.model where 1=1 "+temp+" AND dd.category_code IN('1','2') and wd.is_grant=1";
//        Map<String, Object> map = jdbcTemplate.queryForMap(sql);
        String temp = "other".equals(reMap.get("code"))? " and (d.grant_doctor is null or d.grant_doctor='')":" and d.grant_doctor='"+String.valueOf(reMap.get("code"))+"' ";
        String sql =" select count(DISTINCT d.id) amount from wlyy.wlyy_patient_device p " +
                " LEFT JOIN device.wlyy_devices d on p.device_sn=d.device_code  " +
                " where p.del = 0 "+temp+" and p.id is not null and d.grant_org_code='"+hos.getCode()+"'";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        Map<String,Object> map = result.get(0);
        Integer amount = Integer.valueOf(map.get("amount").toString());
        reMap.put("allNum", amount);
        reMap.put("bindingNum", reMap.get("amount"));
        reMap.put("rate", getRange(Integer.valueOf(reMap.get("amount").toString()), amount, 2));//续签率是 续签量/去年的签约数
        reMap.put("rateNum", getRangeNum(Integer.valueOf(reMap.get("amount").toString()), amount, 2));//续签率是 续签量/去年的签约数
        Integer bingdingAmount = Integer.valueOf(map.get("amount").toString());//绑定量
        Integer paymentAmount = Integer.valueOf(reMap.get("amount").toString());//发放量
        reMap.put("allNum", paymentAmount);
        reMap.put("bindingNum", bingdingAmount);
        reMap.put("rate", getRange(bingdingAmount, paymentAmount, 2));//续签率是 续签量/去年的签约数
        reMap.put("rateNum", getRangeNum(bingdingAmount, paymentAmount, 2));//续签率是 续签量/去年的签约数
        return reMap;
    }
@ -6332,7 +6328,8 @@ public class StatisticsESService {
        if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
            //String time = DateUtil.getStringDateShort();
            String time=  redisTemplate.opsForValue().get("quota:date");
            String sql ="SELECT" +
            resultList = getDeviceLowLevelMapKey(level, low_level,area);
            /*String sql ="SELECT" +
                    " d.device_code," +
                    " pd.doctor," +
                    " pd.doctor_name," +
@ -6353,8 +6350,12 @@ public class StatisticsESService {
            }else if (level==2){
                sql +=" AND d.grant_admin_team IN(SELECT id FROM wlyy_admin_team WHERE available = 1)";
            }
            sqlList = jdbcTemplate.queryForList(sql);
            esModelList = getDeviceBindToTeam(sqlList);
            sqlList = jdbcTemplate.queryForList(sql);*/
            //esModelList = getDeviceBindToTeam(sqlList);
            for (Map<String,Object> map : resultList){
                map.put("amount",map.get("bindingNum"));
            }
        }else {
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date, area, level, index, SaveModel.timeLevel_DDL, low_level);
        }

+ 223 - 178
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java

@ -3,18 +3,17 @@ package com.yihu.wlyy.service.app.survey;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.survey.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.collections.map.HashedMap;
@ -25,6 +24,7 @@ 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.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -39,6 +39,9 @@ import java.util.*;
@Service
@Transactional
public class SurveyScreenResultService extends BaseService {
    @Value("${customerService.url}")
    private String customerUrl;
    @Autowired
    SurveyStatisticsDao surveyStatisticsDao;
    @Autowired
@ -52,28 +55,18 @@ public class SurveyScreenResultService extends BaseService {
    @Autowired
    private SurveyTemplateResultDao surveyTemplateResultDao;
    @Autowired
    private SurveyTemplateAdviceDao surveyTemplateAdviceDao;
    @Autowired
    private SurveyTemplateQuestionsDao surveyTemplateQuestionsDao;
    @Autowired
    private SurveyOptionAnswersDao surveyOptionAnswersDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private SurveyAdviceDao surveyAdviceDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    @Autowired
    private SurveyDao surveyDao;
    @Autowired
    private SurveyQuestionsDao surveyQuestionsDao;
    @Autowired
    private SurveyLabelInfoDao surveyLabelInfoDao;
    @Autowired
    private SurveyQuestionsOptionsDao surveyQuestionsOptionsDao;
    @Autowired
    private SurveyUserDao surveyUserDao;
    @Autowired
    private SurveyFilterDao surveyFilterDao;
@ -82,12 +75,6 @@ public class SurveyScreenResultService extends BaseService {
    @Autowired
    private SurveyQuestionnaireDao surveyQuestionnaireDao;
    @Autowired
    private SurveyTemplateOptionsDao surveyTemplateOptionsDao;
    @Autowired
    private SurveyAnswersDao surveyAnswersDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private SurveyDimensionDao surveyDimensionDao;
    @Autowired
    private SurveyDimensionDetailDao surveyDimensionDetailDao;
@ -99,6 +86,8 @@ public class SurveyScreenResultService extends BaseService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private DoctorService doctorService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -106,6 +95,7 @@ public class SurveyScreenResultService extends BaseService {
    /**
     * 筛查记录结果列表
     *
     * @param pageNo
     * @param pageSize
     * @param doctor
@ -116,78 +106,80 @@ public class SurveyScreenResultService extends BaseService {
     * @return
     * @throws Exception
     */
    public Map<String,Object> getResultList(int pageNo, int pageSize,String doctor,String diseaseType,String dealType,String isDanger,String patientName) throws Exception {
        int start = (pageNo-1)*pageSize;
        String sql = "SELECT ssr.* FROM wlyy_survey_screen_result ssr WHERE 1=1 AND ssr.over = 1 and ssr.source=1 and ssr.doctor='"+doctor+"'";
    public Map<String, Object> getResultList(int pageNo, int pageSize, String doctor, String diseaseType, String dealType, String isDanger, String patientName) throws Exception {
        int start = (pageNo - 1) * pageSize;
        String sql = "SELECT ssr.* FROM wlyy_survey_screen_result ssr WHERE 1=1 AND ssr.over = 1 and ssr.source=1 and ssr.doctor='" + doctor + "'";
        //String countSql = "SELECT count(*) num FROM wlyy_survey_screen_result ssr WHERE 1=1 AND ssr.over = 1 and ssr.doctor='"+doctor+"'";
        if (StringUtils.isNotEmpty(isDanger)){
            sql += " AND ssr.is_danger= "+isDanger;
        if (StringUtils.isNotEmpty(isDanger)) {
            sql += " AND ssr.is_danger= " + isDanger;
        }
        if (StringUtils.isNotEmpty(diseaseType)){
            sql += " AND ssr.disease="+diseaseType;
        if (StringUtils.isNotEmpty(diseaseType)) {
            sql += " AND ssr.disease=" + diseaseType;
        }
        if (StringUtils.isNotEmpty(patientName)){
            sql += " AND ssr.patient_name like '%"+patientName+"%'";
        if (StringUtils.isNotEmpty(patientName)) {
            sql += " AND ssr.patient_name like '%" + patientName + "%'";
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("1",dealType)){
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("1", dealType)) {
            //已预约
            sql += " AND ssr.is_order = 1";
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("2",dealType)){
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("2", dealType)) {
            //已跟踪
            sql += " AND ssr.following= 1";
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("3",dealType)){
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("3", dealType)) {
            //已接诊
            sql += " AND ssr.is_order = 2";
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("4",dealType)){
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("4", dealType)) {
            //待处理
            sql +=" AND ssr.is_order = 0 AND ssr.following= 0";
            sql += " AND ssr.is_order = 0 AND ssr.following= 0";
        }
        List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        sql += " order by ssr.czrq desc limit "+start+","+pageSize;
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        Map<String,Object> map = new HashedMap();
        map.put("num",maps.size());
        map.put("data",surveyScreenResultList);
        sql += " order by ssr.czrq desc limit " + start + "," + pageSize;
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        Map<String, Object> map = new HashedMap();
        map.put("num", maps.size());
        map.put("data", surveyScreenResultList);
        return map;
    }
    /**
     * 筛查模板列表
     *
     * @param pageNo
     * @param pageSize
     * @param labelType
     * @return
     */
    public List<SurveyTemplates> getScreenList(int pageNo,int pageSize,int labelType,String title){
        int start = (pageNo-1)*pageSize;
    public List<SurveyTemplates> getScreenList(int pageNo, int pageSize, int labelType, String title) {
        int start = (pageNo - 1) * pageSize;
        String sql = "SELECT st.* FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_label_info sli ON st.`code`= sli.relation_code" +
                " WHERE st.del = 1 and sli.label="+labelType+"";
        if (StringUtils.isNotEmpty(title)){
            sql += " and st.title like '%"+title+"%'";
                " WHERE st.del = 1 and sli.label=" + labelType + "";
        if (StringUtils.isNotEmpty(title)) {
            sql += " and st.title like '%" + title + "%'";
        }
        sql += " order by st.create_time desc limit "+start+","+pageSize;
        List<SurveyTemplates> surveyTemplatesList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyTemplates.class));
        sql += " order by st.create_time desc limit " + start + "," + pageSize;
        List<SurveyTemplates> surveyTemplatesList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(SurveyTemplates.class));
        return surveyTemplatesList;
    }
    /**
     * 保存筛查结果
     *
     * @param patientCode
     * @param doctor
     * @param source
     * @param jsonData
     */
    public String saveScreenResultAndAnswer(String patientCode,String doctor,int isAgain,int source, JSONObject jsonData)throws Exception{
    public String saveScreenResultAndAnswer(String patientCode, String doctor, int isAgain, int source, JSONObject jsonData) throws Exception {
        System.out.println("********保存筛查结果--jsonData********* " + jsonData);
        String surveyCode = jsonData.get("surveyCode").toString();
        SurveyTemplates surveyTemplates = surveyTemplatesDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        SurveyScreenResult surveyScreenResult =  new SurveyScreenResult();
        SurveyScreenResult surveyScreenResult = new SurveyScreenResult();
        //解析json保存各种答案--获取一维数组
        JSONArray questions = jsonData.getJSONArray("questions");
        int totalScore = 0;
@ -222,12 +214,12 @@ public class SurveyScreenResultService extends BaseService {
            }
        }
        //查询该筛查的结果设置
        SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode,totalScore);
        SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode, totalScore);
        //更新上一条数据为不可再次评估
        List<SurveyScreenResult> surveyScreenResultList = surveyScreenResultDao.findNewOneByTemplateCode(surveyCode,patientCode);
        List<SurveyScreenResult> surveyScreenResultList = surveyScreenResultDao.findNewOneByTemplateCode(surveyCode, patientCode);
        String lastCode = "";
        String originCode = "";
        if (surveyScreenResultList!=null && surveyScreenResultList.size()>0){
        if (surveyScreenResultList != null && surveyScreenResultList.size() > 0) {
            lastCode = surveyScreenResultList.get(0).getCode();
            originCode = surveyScreenResultList.get(0).getOriginCode();
            surveyScreenResultDao.updateNoAgain(lastCode);
@ -236,20 +228,20 @@ public class SurveyScreenResultService extends BaseService {
        surveyScreenResult.setCode(code);
        surveyScreenResult.setSource(source);
        //是来自再次评估
        if (isAgain==1){
        if (isAgain == 1) {
            surveyScreenResult.setParentCode(lastCode);
            surveyScreenResult.setOriginCode(originCode);
        }else {
        } else {
            //来自第一次筛查评分
            surveyScreenResult.setOriginCode(code);
        }
        if (surveyTemplates!=null){
        if (surveyTemplates != null) {
            surveyScreenResult.setTemplateCode(surveyTemplates.getCode());
            surveyScreenResult.setTemplateTitle(surveyTemplates.getTitle());
            surveyScreenResult.setDisease(surveyTemplates.getDiseaseType());
        }
        //来自医生发放和自我评估不一样来源
        if (source==1){
        if (source == 1) {
            surveyScreenResult.setDoctor(doctor);
        }/*else {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
@ -262,7 +254,7 @@ public class SurveyScreenResultService extends BaseService {
        }*/
        surveyScreenResult.setPatientCode(patientCode);
        if (patient!=null){
        if (patient != null) {
            surveyScreenResult.setPatientName(patient.getName());
            surveyScreenResult.setOpenId(patient.getOpenid());
        }
@ -273,38 +265,38 @@ public class SurveyScreenResultService extends BaseService {
        surveyScreenResult.setIsAgain(1);
        surveyScreenResult.setIsEducate(0);
        surveyScreenResult.setScreenResultScore(totalScore);
        if (surveyTemplateResult!=null){
        if (surveyTemplateResult != null) {
            surveyScreenResult.setScreenResultCode(surveyTemplateResult.getCode());
            surveyScreenResult.setIsDanger(surveyTemplateResult.getWarning());
            surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
        }
        surveyScreenResultDao.save(surveyScreenResult);
        managerQuestionnaireService.saveAnswer(patientCode,code,jsonData);
        managerQuestionnaireService.saveAnswer(patientCode, code, jsonData);
        return code;
    }
    public JSONObject getScreenResultDetail(String code)throws Exception{
    public JSONObject getScreenResultDetail(String code) throws Exception {
        JSONObject json = new JSONObject();
        //登记信息
        String infoSql = "SELECT ssr.*,p.idcard FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_patient p ON ssr.patient_code=p.code where ssr.code ='"+code+"'";
        Map<String,Object> infoMap = jdbcTemplate.queryForMap(infoSql);
        if (infoMap==null || infoMap.size()==0){
            json.put(code,-1);
            json.put("message","没有改筛查结果!");
        String infoSql = "SELECT ssr.*,p.idcard FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_patient p ON ssr.patient_code=p.code where ssr.code ='" + code + "'";
        Map<String, Object> infoMap = jdbcTemplate.queryForMap(infoSql);
        if (infoMap == null || infoMap.size() == 0) {
            json.put(code, -1);
            json.put("message", "没有改筛查结果!");
            return json;
        }
        String idcard = String.valueOf(infoMap.get("idcard"));
        infoMap.put("sex",IdCardUtil.getSexForIdcard_new(idcard));
        infoMap.put("age",IdCardUtil.getAgeForIdcard(idcard));
        infoMap.put("sex", IdCardUtil.getSexForIdcard_new(idcard));
        infoMap.put("age", IdCardUtil.getAgeForIdcard(idcard));
        String templateCode = String.valueOf(infoMap.get("template_code"));
        String doctorCode = String.valueOf(infoMap.get("doctor"));
        String patientCode = String.valueOf(infoMap.get("patient_code"));
        Doctor doctor = doctorDao.findByCode(doctorCode);
        if (doctor!=null){
            infoMap.put("level",doctor.getLevel());
            infoMap.put("doctorName",doctor.getName());
        if (doctor != null) {
            infoMap.put("level", doctor.getLevel());
            infoMap.put("doctorName", doctor.getName());
        }
        json.put("info",infoMap);
        json.put("info", infoMap);
        /*String healthSql ="SELECT value1,value2 FROM device.wlyy_patient_health_index WHERE user='"+patientCode+"' AND type=3 ORDER BY record_date DESC LIMIT 1";
        List<Map<String,Object>> healthMapList = jdbcTemplate.queryForList(healthSql);
        if (healthMapList!=null && healthMapList.size()>0){
@ -313,170 +305,171 @@ public class SurveyScreenResultService extends BaseService {
        //题目和答案
        List<SurveyTemplateQuestions> questionList = surveyTemplateQuestionsDao.findById(templateCode);
        Map<String,Object> answerMap = new HashMap<>();
        Map<String, Object> answerMap = new HashMap<>();
        String sql = "SELECT soa.*,sto.score,sto.content FROM wlyy_survey_option_answers soa LEFT JOIN wlyy_survey_template_options sto ON soa.options_code= sto.code WHERE soa.screen_result_code=? AND soa.patient=? AND soa.survey_code=?";
        List<Map<String,Object>> optionAnswersList = jdbcTemplate.queryForList(sql,new Object[]{code,patientCode,templateCode});
        for (SurveyTemplateQuestions surveyTemplateQuestions : questionList){
            Map<String,Object> map = new HashMap<>();
            map.put("question",surveyTemplateQuestions);
        List<Map<String, Object>> optionAnswersList = jdbcTemplate.queryForList(sql, new Object[]{code, patientCode, templateCode});
        for (SurveyTemplateQuestions surveyTemplateQuestions : questionList) {
            Map<String, Object> map = new HashMap<>();
            map.put("question", surveyTemplateQuestions);
            String qusCode = surveyTemplateQuestions.getCode();
            for (Map<String,Object> option : optionAnswersList){
                if (option.get("question_code").equals(qusCode)){
                    map.put("option",option);
            for (Map<String, Object> option : optionAnswersList) {
                if (option.get("question_code").equals(qusCode)) {
                    map.put("option", option);
                }
            }
            answerMap.put(surveyTemplateQuestions.getSort()+"",map);
            answerMap.put(surveyTemplateQuestions.getSort() + "", map);
        }
        json.put("answer",answerMap);
        json.put("answer", answerMap);
        //结果
        String reultSql ="SELECT ssr.screen_result_score,ssr.screen_result,str.advice FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_survey_template_result str ON ssr.screen_result_code = str.code WHERE ssr.code='"+code+"'";
        Map<String,Object> resultMap = jdbcTemplate.queryForMap(reultSql);
        String reultSql = "SELECT ssr.screen_result_score,ssr.screen_result,str.advice FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_survey_template_result str ON ssr.screen_result_code = str.code WHERE ssr.code='" + code + "'";
        Map<String, Object> resultMap = jdbcTemplate.queryForMap(reultSql);
        int following = Integer.parseInt(String.valueOf(infoMap.get("following")));
        int order = Integer.parseInt(String.valueOf(infoMap.get("is_order")));
        if (order>0){
        if (order > 0) {
            //已转诊
            String doctorSql ="SELECT pr.doctor_name FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_patient_reservation pr ON ssr.reservation_code= pr.`code` where ssr.`code`='"+code+"'";
            List<String> list= jdbcTemplate.queryForList(doctorSql,String.class);
            if (list!=null && list.size()>0){
                json.put("specialDoctorName",list.get(0));
            String doctorSql = "SELECT pr.doctor_name FROM wlyy_survey_screen_result ssr LEFT JOIN wlyy_patient_reservation pr ON ssr.reservation_code= pr.`code` where ssr.`code`='" + code + "'";
            List<String> list = jdbcTemplate.queryForList(doctorSql, String.class);
            if (list != null && list.size() > 0) {
                json.put("specialDoctorName", list.get(0));
            }
        }else if (following==1){
        } else if (following == 1) {
            String adviceCodes = String.valueOf(infoMap.get("advice_code"));
            List<SurveyAdvice> surveyAdviceList = new ArrayList<>();
            if (StringUtils.isNotEmpty(adviceCodes)){
            if (StringUtils.isNotEmpty(adviceCodes)) {
                String[] advicesStr = adviceCodes.split(",");
                for (String adviceCode : advicesStr){
                for (String adviceCode : advicesStr) {
                    surveyAdviceList.add(surveyAdviceDao.getByCode(adviceCode));
                }
            }
            resultMap.put("doctorAdvice",surveyAdviceList);
            resultMap.put("doctorOtherAdvice",infoMap.get("other_advice"));
            resultMap.put("doctorAdvice", surveyAdviceList);
            resultMap.put("doctorOtherAdvice", infoMap.get("other_advice"));
        }
        json.put("result",resultMap);
        json.put("result", resultMap);
        return json;
    }
    public List<Map<String,Object>> getTemplateAdviceList(String templateCode){
        String sql ="SELECT st.template_code,sa.code adviceCode,sa.advice FROM wlyy_survey_template_advice st LEFT JOIN wlyy_survey_advice sa ON st.advice_code=sa.`code` WHERE st.template_code='"+templateCode+"'";
    public List<Map<String, Object>> getTemplateAdviceList(String templateCode) {
        String sql = "SELECT st.template_code,sa.code adviceCode,sa.advice FROM wlyy_survey_template_advice st LEFT JOIN wlyy_survey_advice sa ON st.advice_code=sa.`code` WHERE st.template_code='" + templateCode + "'";
        return jdbcTemplate.queryForList(sql);
    }
    public void updateAfterFollowing(String code,String adviceCodes,String otherAdvice)throws Exception{
        String sql ="UPDATE wlyy_survey_screen_result SET following=1,advice_code=?";
        if (StringUtils.isNotEmpty(otherAdvice)){
    public void updateAfterFollowing(String code, String adviceCodes, String otherAdvice) throws Exception {
        String sql = "UPDATE wlyy_survey_screen_result SET following=1,advice_code=?";
        if (StringUtils.isNotEmpty(otherAdvice)) {
            sql += " ,other_advice=?";
        }
        sql +=" where code=?";
        if (StringUtils.isNotEmpty(otherAdvice)){
            jdbcTemplate.update(sql,new Object[]{adviceCodes,otherAdvice,code});
        }else {
            jdbcTemplate.update(sql,new Object[]{adviceCodes,code});
        sql += " where code=?";
        if (StringUtils.isNotEmpty(otherAdvice)) {
            jdbcTemplate.update(sql, new Object[]{adviceCodes, otherAdvice, code});
        } else {
            jdbcTemplate.update(sql, new Object[]{adviceCodes, code});
        }
    }
    public void updateColume(String colume,Object value,String code){
        String sql ="UPDATE wlyy_survey_screen_result SET "+colume+"=? where code=?";
        jdbcTemplate.update(sql,new Object[]{value,code});
    public void updateColume(String colume, Object value, String code) {
        String sql = "UPDATE wlyy_survey_screen_result SET " + colume + "=? where code=?";
        jdbcTemplate.update(sql, new Object[]{value, code});
    }
    public Map<String,Object> patientGetList(int pageNo,int pageSize,int labelType,String patientCode){
        Map<String,Object> map = new HashedMap();
        List<SurveyTemplates> templates = getScreenList(pageNo,pageSize,labelType,null);
        List<Map<String,Object>> mapList = new ArrayList<>();
        for (SurveyTemplates surveyTemplates : templates){
            Map<String,Object> sMap = new HashedMap();
            sMap.put("surveyTemplate",surveyTemplates);
            int count =  surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode,surveyTemplates.getCode(),2).size();
            sMap.put("myRecordCount",count);
    public Map<String, Object> patientGetList(int pageNo, int pageSize, int labelType, String patientCode) {
        Map<String, Object> map = new HashedMap();
        List<SurveyTemplates> templates = getScreenList(pageNo, pageSize, labelType, null);
        List<Map<String, Object>> mapList = new ArrayList<>();
        for (SurveyTemplates surveyTemplates : templates) {
            Map<String, Object> sMap = new HashedMap();
            sMap.put("surveyTemplate", surveyTemplates);
            int count = surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode, surveyTemplates.getCode(), 2).size();
            sMap.put("myRecordCount", count);
            mapList.add(sMap);
        }
        map.put("screenList",mapList);
        map.put("screenList", mapList);
        return map;
    }
    public List<SurveyScreenResult> patientGetResult(String patientCode){
        Map<String,Object> map = new HashedMap();
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result WHERE source=2 and patient_code='"+patientCode+"' ORDER BY czrq DESC) a  GROUP BY a.template_code";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
    public List<SurveyScreenResult> patientGetResult(String patientCode) {
        Map<String, Object> map = new HashedMap();
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result WHERE source=2 and patient_code='" + patientCode + "' ORDER BY czrq DESC) a  GROUP BY a.template_code";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        return surveyScreenResultList;
    }
    public List<Map<String,Object>> getResultByTemplateCode(int pageNo,int pageSize,String templateCode,String patientCode){
        int start = (pageNo-1)*pageSize;
        String sql ="SELECT st.*,ssr.code screenCode,ssr.screen_result,ssr.screen_result_score,ssr.czrq as screenCzrq,ssr.is_again FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_screen_result ssr ON st.code = ssr.template_code WHERE ssr.source=2 and st.`code`='"+templateCode+"' AND ssr.patient_code='"+patientCode+"' order by ssr.czrq limit ?,?";
        return jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
    public List<Map<String, Object>> getResultByTemplateCode(int pageNo, int pageSize, String templateCode, String patientCode) {
        int start = (pageNo - 1) * pageSize;
        String sql = "SELECT st.*,ssr.code screenCode,ssr.screen_result,ssr.screen_result_score,ssr.czrq as screenCzrq,ssr.is_again FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_screen_result ssr ON st.code = ssr.template_code WHERE ssr.source=2 and st.`code`='" + templateCode + "' AND ssr.patient_code='" + patientCode + "' order by ssr.czrq limit ?,?";
        return jdbcTemplate.queryForList(sql, new Object[]{start, pageSize});
    }
    public Map<String,Object> screenStatics(String doctor){
        Map<String,Object> resultMap = new HashedMap();
        String userSql = "SELECT DISTINCT(template_code) FROM wlyy_survey_screen_result WHERE doctor = '"+doctor+"' and source=1";
        List<String> userList = jdbcTemplate.queryForList(userSql,String.class);
    public Map<String, Object> screenStatics(String doctor) {
        Map<String, Object> resultMap = new HashedMap();
        String userSql = "SELECT DISTINCT(template_code) FROM wlyy_survey_screen_result WHERE doctor = '" + doctor + "' and source=1";
        List<String> userList = jdbcTemplate.queryForList(userSql, String.class);
        //使用筛查表数量
        resultMap.put("useTemplateCount",userList.size());
        String sql = "SELECT * FROM wlyy_survey_screen_result WHERE doctor='"+doctor+"' and source=1";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        resultMap.put("useTemplateCount", userList.size());
        String sql = "SELECT * FROM wlyy_survey_screen_result WHERE doctor='" + doctor + "' and source=1";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        //下发问卷数量
        resultMap.put("grantCount",surveyScreenResultList.size());
        resultMap.put("grantCount", surveyScreenResultList.size());
        int overCount = 0;
        int warnCount = 0;
        int followCount = 0;
        int orderCount = 0 ;
        int orderCount = 0;
        int againCount = 0;
        int eduCount = 0;
        for (SurveyScreenResult surveyScreenResult : surveyScreenResultList){
            if (surveyScreenResult.getOver()==1){
        for (SurveyScreenResult surveyScreenResult : surveyScreenResultList) {
            if (surveyScreenResult.getOver() == 1) {
                overCount++;
            }
            if (surveyScreenResult.getIsDanger()==1){
            if (surveyScreenResult.getIsDanger() == 1) {
                warnCount++;
            }
            if (surveyScreenResult.getFollowing()==1){
            if (surveyScreenResult.getFollowing() == 1) {
                followCount++;
            }
            if (surveyScreenResult.getIsOrder()>0){
            if (surveyScreenResult.getIsOrder() > 0) {
                orderCount++;
            }
            if (StringUtils.isNotEmpty(surveyScreenResult.getParentCode())){
            if (StringUtils.isNotEmpty(surveyScreenResult.getParentCode())) {
                againCount++;
            }
            if (surveyScreenResult.getIsEducate()==1){
            if (surveyScreenResult.getIsEducate() == 1) {
                eduCount++;
            }
        }
        //筛查记录
        resultMap.put("overCount",overCount);
        resultMap.put("overCount", overCount);
        //疑似高危
        resultMap.put("dangetCount",warnCount);
        resultMap.put("dangetCount", warnCount);
        //健康跟踪
        resultMap.put("followCount",followCount);
        resultMap.put("followCount", followCount);
        //已跟踪
        resultMap.put("orderCount",orderCount);
        resultMap.put("orderCount", orderCount);
        //再次评估
        resultMap.put("againCount",againCount);
        resultMap.put("againCount", againCount);
        //健康教育
        resultMap.put("eduCount",eduCount);
        return  resultMap;
        resultMap.put("eduCount", eduCount);
        return resultMap;
    }
    public int getAmountByDoctor(String json,String doctorCode) {
        return getCountByDoctor(json,doctorCode).size();
    public int getAmountByDoctor(String json, String doctorCode) {
        return getCountByDoctor(json, doctorCode).size();
    }
    public List<String> getCountByDoctor(String json,String doctorCode) {
    public List<String> getCountByDoctor(String json, String doctorCode) {
//        1.服务 2.健康 3疾病
        JSONObject jsonObject = new JSONObject(json);
        String sql = "";
        String sex = jsonObject.get("sex").toString();
        String str = "SELECT DISTINCT lb.patient FROM wlyy_sign_patient_label_info lb,(SELECT DISTINCT ff.patient FROM wlyy_sign_family_server s, " +
                " (SELECT f.`code`,f.patient FROM wlyy_sign_family f,wlyy_patient p WHERE p.CODE=f.patient and (f.doctor='"+doctorCode+"' OR  f.doctor_health='"+doctorCode+"')";
                " (SELECT f.`code`,f.patient FROM wlyy_sign_family f,wlyy_patient p WHERE p.CODE=f.patient and (f.doctor='" + doctorCode + "' OR  f.doctor_health='" + doctorCode + "')";
        if (!"0".equals(sex)) {
            str += " AND p.sex=  " + sex +
                    " AND f.STATUS>0 AND p.`openid` IS NOT NULL AND p.`openid`!='')ff WHERE ff.CODE=s.sign_code ";
                    " AND f.STATUS>0 AND f.expenses_status = 1 AND p.`openid` IS NOT NULL AND p.`openid`!='')ff WHERE ff.CODE=s.sign_code ";
        } else {
            str += " AND f.STATUS>0 AND p.`openid`IS NOT NULL AND p.`openid`!='')ff WHERE ff.CODE=s.sign_code ";
            str += " AND f.STATUS>0 AND f.expenses_status = 1 AND p.`openid`IS NOT NULL AND p.`openid`!='')ff WHERE ff.CODE=s.sign_code ";
        }
        JSONArray service = jsonObject.getJSONArray("service");
        String ser = "";
@ -532,17 +525,17 @@ public class SurveyScreenResultService extends BaseService {
            dis += " OR ";
        }
        if (StringUtils.isNotEmpty(dis)) {
            disSql= " (lb.label_type =3 AND ( " + dis.substring(0, dis.lastIndexOf("OR")) + " )  )";
            disSql = " (lb.label_type =3 AND ( " + dis.substring(0, dis.lastIndexOf("OR")) + " )  )";
        }
        if (StringUtils.isEmpty(heal) && StringUtils.isEmpty(dis)) {
            sql = str;
        } else if (StringUtils.isEmpty(heal) && StringUtils.isNotEmpty(dis)) {
            sql = str + " AND " +disSql;
            sql = str + " AND " + disSql;
        } else if (StringUtils.isNotEmpty(heal) && StringUtils.isEmpty(dis)) {
            sql = str + " AND " +healSql;
            sql = str + " AND " + healSql;
        } else if (StringUtils.isNotEmpty(heal) && StringUtils.isNotEmpty(dis)) {
            sql = str + " AND ( " + disSql +" OR " +healSql +" ) ";
            sql = str + " AND ( " + disSql + " OR " + healSql + " ) ";
        }
        System.out.println("=====query sql =======>>>>" + sql);
@ -699,7 +692,7 @@ public class SurveyScreenResultService extends BaseService {
        countJson.put("disease", diseaList);
        countJson.put("healthCondition", healthList);
        countJson.put("service", servList);
        List<String> codes = getCountByDoctor(countJson.toString(),doctor);
        List<String> codes = getCountByDoctor(countJson.toString(), doctor);
        int amount = codes.size();
        for (String code : codes) {
//            String code = patient.get("patient").toString();
@ -749,7 +742,7 @@ public class SurveyScreenResultService extends BaseService {
                }
//            });
            }*/
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","scwj");
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey", "scwj");
            String remark = templateConfig.getRemark();
            String keyword1 = templateConfig.getKeyword1();
            String wxTemplateCode = templateCode;
@ -760,20 +753,20 @@ public class SurveyScreenResultService extends BaseService {
                        String name = null;
                        String openId = null;
                        String first = null;
                        String screenCode =null;
                        String screenCode = null;
                        try {
                            screenCode = saveAfterBatchScreen(c,openId,name,doctor,wxTemplateCode);
                            screenCode = saveAfterBatchScreen(c, openId, name, doctor, wxTemplateCode);
                            p = patientDao.findByCode(c);
                            name = p.getName();
                            openId = p.getOpenid();
                            json.put("keyword1", keyword1);
                            json.put("keyword2", sdf.format(new Date()));
                            json.put("survey", wxTemplateCode+"_"+doctor);
                            json.put("survey", wxTemplateCode + "_" + doctor);
                            json.put("toUser", c);
                            json.put("url","jkpg/html/wx-template-message.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+c+"&toName="+name+"&screenCode="+screenCode);
                            json.put("url", "jkpg/html/wx-template-message.html?survey=" + wxTemplateCode + "&doctor=" + doctor + "&toUser=" + c + "&toName=" + name + "&screenCode=" + screenCode);
//                          String first = name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。";
                            first = templateConfig.getFirst();
                            first = first.replace("key1",(name==null?"":name));
                            first = first.replace("key1", (name == null ? "" : name));
                            json.put("first", first);
                            json.put("remark", remark);
                        } catch (JSONException e) {
@ -785,7 +778,7 @@ public class SurveyScreenResultService extends BaseService {
                            logger.error("json =======>" + json);
//                            PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
                            pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);
                        }else {
                        } else {
                            //发送代理人
                            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
                            if (jsonArray != null && jsonArray.length() > 0) {
@ -795,7 +788,7 @@ public class SurveyScreenResultService extends BaseService {
                                    if (StringUtils.isNotBlank(member.getOpenid())) {
                                        json.remove("toUser");
                                        json.put("toUser", member.getCode());
                                        json.put("url","jkpg/html/wx-template-message.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+member.getCode()+"&toName="+member.getName()+"&screenCode="+screenCode);
                                        json.put("url", "jkpg/html/wx-template-message.html?survey=" + wxTemplateCode + "&doctor=" + doctor + "&toUser=" + member.getCode() + "&toName=" + member.getName() + "&screenCode=" + screenCode);
                                        json.remove("first");
                                        try {
                                            json.put("keyword1", keyword1);
@ -1028,23 +1021,23 @@ public class SurveyScreenResultService extends BaseService {
        return surveyCode;
    }
    public String saveAfterBatchScreen(String patientCode,String openId,String patientName,String doctorCode,String surveyCode){
        SurveyScreenResult surveyScreenResult =  new SurveyScreenResult();
    public String saveAfterBatchScreen(String patientCode, String openId, String patientName, String doctorCode, String surveyCode) {
        SurveyScreenResult surveyScreenResult = new SurveyScreenResult();
        SurveyTemplates surveyTemplates = surveyTemplatesDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        String code = getCode();
        surveyScreenResult.setCode(code);
        if (surveyTemplates!=null){
        if (surveyTemplates != null) {
            surveyScreenResult.setTemplateCode(surveyTemplates.getCode());
            surveyScreenResult.setTemplateTitle(surveyTemplates.getTitle());
            surveyScreenResult.setDisease(surveyTemplates.getDiseaseType());
        }
        surveyScreenResult.setDoctor(doctorCode);
        surveyScreenResult.setPatientCode(patientCode);
        if (patient!=null){
        if (patient != null) {
            surveyScreenResult.setPatientName(patient.getName());
            surveyScreenResult.setOpenId(patient.getOpenid());
        }else {
        } else {
            surveyScreenResult.setOpenId(openId);
            surveyScreenResult.setPatientName(patientName);
        }
@ -1063,10 +1056,10 @@ public class SurveyScreenResultService extends BaseService {
    }
    public String updateScreenAndSaveAnswer(String patientCode,String screenCode, JSONObject jsonData)throws Exception{
    public String updateScreenAndSaveAnswer(String patientCode, String screenCode, JSONObject jsonData) throws Exception {
        System.out.println("********保存筛查结果--jsonData********* " + jsonData);
        String surveyCode = jsonData.get("surveyCode").toString();
        SurveyScreenResult surveyScreenResult =  surveyScreenResultDao.getSurveyScreenResultByCode(screenCode);
        SurveyScreenResult surveyScreenResult = surveyScreenResultDao.getSurveyScreenResultByCode(screenCode);
        //解析json保存各种答案--获取一维数组
        JSONArray questions = jsonData.getJSONArray("questions");
        int totalScore = 0;
@ -1088,7 +1081,7 @@ public class SurveyScreenResultService extends BaseService {
            }
        }
        //查询该筛查的结果设置
        SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode,totalScore);
        SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode, totalScore);
       /* surveyScreenResult.setOver(1);
        surveyScreenResult.setCzrq(new Date());
        surveyScreenResult.setScreenResultScore(totalScore);
@ -1097,11 +1090,63 @@ public class SurveyScreenResultService extends BaseService {
            surveyScreenResult.setIsDanger(surveyTemplateResult.getWarning());
            surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
        }*/
       String sql ="UPDATE wlyy_survey_screen_result SET over=1,czrq=?,screen_result_code=?,screen_result=?,screen_result_score=?,is_danger=? WHERE code=?";
       jdbcTemplate.update(sql,new Object[]{new Date(),surveyTemplateResult.getCode(),surveyTemplateResult.getResult(),totalScore,surveyTemplateResult.getWarning(),screenCode});
        String sql = "UPDATE wlyy_survey_screen_result SET over=1,czrq=?,screen_result_code=?,screen_result=?,screen_result_score=?,is_danger=? WHERE code=?";
        jdbcTemplate.update(sql, new Object[]{new Date(), surveyTemplateResult.getCode(), surveyTemplateResult.getResult(), totalScore, surveyTemplateResult.getWarning(), screenCode});
        //surveyScreenResultDao.updateScreenAndSaveAnswer(new Date(),totalScore,surveyTemplateResult.getCode(),surveyTemplateResult.getResult(),surveyTemplateResult.getWarning(),screenCode);
        managerQuestionnaireService.saveAnswer(patientCode,surveyScreenResult.getCode(),jsonData);
        managerQuestionnaireService.saveAnswer(patientCode, surveyScreenResult.getCode(), jsonData);
        return screenCode;
    }
    //获取筛查居民信息
    public List<Map<String, Object>> initPatient(String doctor, String labelType, String serverType, Long teamCode) {
        String sql = "SELECT DISTINCT p.`code` as servicePatientCode, p.`name` as servicePatientName, t1.ssc,t1.idcard,t1.mobile,t1.hospital,t1.hospital_name as hospitalName, h.town,h.town_name as townName " +
                "FROM  wlyy_sign_family t1  LEFT JOIN wlyy_patient p on p. CODE = t1.patient   " +
                "LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = " + labelType + " and t2.status=1 " +
                "RIGHT JOIN wlyy_sign_family_server s on s.sign_code = t1.code" +
                "LEFT JOIN dm_hospital h on t1.hospital = h.`code` " +
                "WHERE ( t1.doctor = ? OR t1.doctor_health = ?) AND t1. STATUS > 0  and t1.expenses_status = 1 AND t1.admin_team_code = ? " +
                "AND p.openid IS NOT NULL AND p.openid <>'' ";
        if(StringUtils.isNotBlank(serverType)){
            sql = sql.replace("on s.sign_code = t1.code", "on s.sign_code = t1.code and s.server_type in (" + serverType + ") ");
        }
        Object[] args = new Object[]{doctor, doctor, teamCode};
        List<Map<String, Object>> patientInfo = jdbcTemplate.queryForList(sql, args);
        return patientInfo;
    }
    /**
     * 调用集美客服派发问卷协同服务接口
     *
     * @param jsonData
     * @param patientInfo
     * @param doctor
     * @return
     * @throws Exception
     */
    public String createWorkOrder(String jsonData, List<Map<String, Object>> patientInfo, String doctor) throws Exception {
        JSONObject object = new JSONObject(jsonData);
        JSONArray patientInfos = new JSONArray(patientInfo);
        //获取关联业务名称
        if(object.getInt("type") == 4){
            Survey survey = surveyDao.findById(object.getString("relationCode"));
            object.put("relationCodeName", survey.getTitle());
        }else if(object.getInt("type") == 5){
            SurveyTemplates templates = surveyTemplatesDao.findById(object.getString("relationCode"));
            object.put("relationCodeName", templates.getTitle());
        }
        Doctor d = doctorService.findDoctorByCode(doctor);
        object.put("hospital", d.getHospital());
        object.put("hospitalName", d.getHospitalName());
        object.put("createUser", d.getCode());
        object.put("createUserName", d.getName());
        object.put("createUserType", 1);
        Map<String, Object> param = new HashedMap();
        param.put("patientInfo", patientInfos.toString());
        param.put("jsonData", object.toString());
        HttpResponse response = null;
        response = HttpUtils.doPost(customerUrl + "synergy/questionnaire/createWorkOrder", param);
        JSONObject rs = new JSONObject(response.getContent());
        return rs.getString("data");
    }
}

+ 415 - 22
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java

@ -1,24 +1,37 @@
package com.yihu.wlyy.service.imm;
import com.yihu.es.entity.PatientRemindRecordESDO;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.imm.ChildFamilyImmune;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import com.yihu.wlyy.entity.imm.ChildInfo;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.imm.ChildFamilyImmuneDao;
import com.yihu.wlyy.repository.imm.ChildImmuneVaccinDao;
import com.yihu.wlyy.repository.imm.ChildInfoDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.guahao.ImmuneService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.searchbox.client.JestClient;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.sql.Array;
import java.util.*;
/**
 * 家人免疫关系业务层
@ -27,7 +40,9 @@ import java.util.UUID;
 */
@Service
public class ChildFamilyImmuneService extends BaseService {
	
	private static org.slf4j.Logger logger = LoggerFactory.getLogger(ChildFamilyImmuneService.class);
	@Autowired
	private ChildFamilyImmuneDao childFamilyImmuneDao;
	@Autowired
@ -36,7 +51,25 @@ public class ChildFamilyImmuneService extends BaseService {
	JdbcTemplate jdbcTemplate;
	@Autowired
	private ChildImmuneVaccinDao childImmuneVaccinDao;
	
	@Autowired
	private ImmuneService immuneService;
	@Autowired
	private ElasticFactory elasticFactory;
	@Autowired
	private ElastricSearchSave elastricSearchSave;
	@Value("${es.type.patientRemindRecord}")
	private String esType;
	@Value("${es.index.patientRemindRecord}")
	private String esIndex;
	@Autowired
	private WechatTemplateConfigDao templateConfigDao;
	@Autowired
	private DoctorDao doctorDao;
	@Autowired
	private PushMsgTask pushMsgTask;
	@Autowired
	private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
	/**
	 * 绑定家庭成员免疫关系
	 * @param childInfo
@ -47,30 +80,30 @@ public class ChildFamilyImmuneService extends BaseService {
	 */
	@Transactional
	public void addFamilyMembers(ChildInfo childInfo, String uid, String idcard, String ssc,Integer relation) throws Exception {
		
		ChildFamilyImmune childFamilyImmune = new ChildFamilyImmune();
		if(childInfo.getId() == null){
			childInfoDao.save(childInfo);
		}else{
			childFamilyImmune = childFamilyImmuneDao.findByfaAndChildCodeAndFamilyCode(childInfo.getCode(),uid);
			
			if(childFamilyImmune == null){
				childFamilyImmune = new ChildFamilyImmune();
			}else{
				throw new Exception("您已绑定过该新生儿,无法重复绑定");
			}
		}
		
		childFamilyImmune.setCode(UUID.randomUUID().toString());
		childFamilyImmune.setChildCode(childInfo.getCode());
		childFamilyImmune.setFamilyCode(uid);
		childFamilyImmune.setDel(0);
		childFamilyImmune.setCreate_time(new Date());
		childFamilyImmune.setRelation(relation);
		
		childFamilyImmuneDao.save(childFamilyImmune);
	}
	
	/**
	 * 获取家人免疫关系成员列表
	 * @param repUID
@ -89,37 +122,397 @@ public class ChildFamilyImmuneService extends BaseService {
				"from wlyy_child_family_immune a " +
				"join wlyy_child_info b on b.code = a.child_code and b.del = 0 " +
				"where a.del = 0 and a.family_code = '"+repUID+"'";
		
		List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
		return rs;
	}
	
	/**
	 * 获取签约居民待接种疫苗列表
	 * @param doctorcode
	 * @param doctorcode,limitType 1要分页 0不用分页
	 * @return
	 */
	public List<Map<String,Object>> getImmVaccinList(String doctorcode,int pageNo,int pageSize) {
		String sql = "select t.*,m.family_name,m.child_name,m.birthday from wlyy_child_immune_vaccin t " +
	public List<Map<String,Object>> getImmVaccinList(String doctorcode,int pageNo,int pageSize,int limitType) {
		String sql = "select DISTINCT t.*,m.child_name,m.birthday,m.childCode from wlyy_child_immune_vaccin t " +
				" inner join ( " +
				" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday from  wlyy_child_family_immune a " +
				" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday,c.`code` AS childCode from  wlyy_child_family_immune a " +
				" inner join (select patient,name from wlyy_sign_family where type in (1,2) and `status` = 1 and expenses_status = 1 and doctor = '"+doctorcode+"') b " +
				" on a.family_code = b.patient " +
				" left join wlyy_child_info c on c.`code` = a.child_code " +
				") m on m.barcode = t.barcode ";
		int start = (pageNo-1)*pageSize;
		sql +=" limit "+start+","+pageSize;
		if (limitType==1){
			int start = (pageNo-1)*pageSize;
			sql +=" limit "+start+","+pageSize;
		}
		List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
		for (Map<String,Object> map : rs){
			String childCode = String.valueOf(map.get("childCode"));
			String familyName="";
			String familySql ="SELECT" +
					" a.*, b. NAME AS family_name," +
					" c. NAME AS child_name," +
					" c.barcode AS barcode," +
					" c.birthday AS birthday," +
					" c.`code` AS childCode" +
					" FROM" +
					" wlyy_child_family_immune a" +
					" INNER JOIN (" +
					" SELECT" +
					" patient," +
					" NAME" +
					" FROM" +
					" wlyy_sign_family" +
					" WHERE" +
					" type IN (1, 2)" +
					" AND `status` = 1" +
					" AND expenses_status = 1" +
					" AND doctor = '"+doctorcode+"'" +
					" ) b ON a.family_code = b.patient" +
					" LEFT JOIN wlyy_child_info c ON c.`code` = a.child_code where  a.child_code='"+childCode+"'";
			List<Map<String,Object>> familyList = jdbcTemplate.queryForList(familySql);
			for (Map<String,Object> map1 : familyList){
				familyName +=String.valueOf(map1.get("family_name"))+"、";
			}
			if (familyName.length()>1){
				familyName = familyName.substring(0,familyName.length()-1);
			}
			map.put("family_name",familyName);
		}
		return rs;
	}
	
	/**
	 * 根据免疫条码获取待接种免疫记录
	 * @param barcode
	 * @return
	 */
	public ChildImmuneVaccin getChildImmuneVaccinByBarcode(String barcode){
	public List<ChildImmuneVaccin> getChildImmuneVaccinByBarcode(String barcode){
		return childImmuneVaccinDao.getChildImmuneVaccinByBarcode(barcode);
	}
	public int alertImmVacclinByChildInfoCodes(String alertDataJsonStr, String doctor)throws Exception{
		if (StringUtils.isEmpty(alertDataJsonStr)){
			return -1;
		}
		Doctor doctorObj = doctorDao.findByCode(doctor);
		String doctorName = "";
		String doctorLevel = "";
		if (doctorObj!=null){
			doctorName = doctorObj.getName();
			if (doctorObj.getLevel()==1) {
				doctorLevel="专科";
			}
			if (doctorObj.getLevel()==2) {
				doctorLevel="全科";
			}
			if (doctorObj.getLevel()==3){
				doctorLevel="健管";
			}
		}
		List<PatientRemindRecordESDO> patientRemindRecordESDOList = new ArrayList<>();
		JSONArray jsonArray = new JSONArray(alertDataJsonStr);
		for (int i=0;i<jsonArray.length();i++){
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			String childCode = jsonObject.getString("childCode");
			String childName = jsonObject.getString("childName");
			String vaccinName = jsonObject.getString("vaccinName");
			String vaccinCode = jsonObject.getString("vaccinCode");
			String sql ="SELECT" +
					" cfi.relation," +
					" p.`code`," +
					" p.`name`," +
					" p.openid" +
					" FROM" +
					" wlyy_child_family_immune cfi" +
					" LEFT JOIN wlyy_patient p ON cfi.family_code = p.`code`" +
					" WHERE" +
					" cfi.child_code = '"+childCode+"'" +
					" AND cfi.del = 0 and (p.openid is not null or p.openid !='')";
			List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
			if (list.size()==0){
				return -10000;
			}
			List<String> openIdList = new ArrayList<>();
			for (Map<String,Object> map : list){
				//如果父母亲都在就都发
				if (!openIdList.contains(String.valueOf(map.get("openid")))){
					if (("1".equals(String.valueOf(map.get("relation"))) || "2".equals(String.valueOf(map.get("relation")))) && StringUtils.isNotBlank(String.valueOf(map.get("openid")))){
						boolean flag =true;
						try {
							WechatTemplateConfig temp = templateConfigDao.findByScene("template_deal_with", "ymjztx");
							JSONObject json = new JSONObject();
							json.put("toUser",String.valueOf(map.get("code")));
							json.put("keyword1", temp.getKeyword1().replace("key1",DateUtil.dateToStr(new Date(), "yyyy-MM-dd")));
							json.put("keyword2", temp.getKeyword2().replace("key1", doctorName+"("+doctorLevel+")"));
							json.put("remark", temp.getRemark());
							json.put("first", temp.getFirst().replace("key1",String.valueOf(map.get("name"))).replace("key2", childName).replace("key3",vaccinName));
							logger.info("weiTempJOSN:"+json.toString());
							pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 24,String.valueOf(map.get("openid")) , String.valueOf(map.get("name")), json);
						}catch (Exception e){
							e.printStackTrace();
							flag = false;
						}
						//发送微信消息并且插入一条es提醒数据
						PatientRemindRecordESDO patientRemindRecordESDO =  new PatientRemindRecordESDO();
						patientRemindRecordESDO.setCode(getCode());
						patientRemindRecordESDO.setPatient(String.valueOf(map.get("code")));
						patientRemindRecordESDO.setPatientName(String.valueOf(map.get("name")));
						patientRemindRecordESDO.setDoctor(doctor);
						patientRemindRecordESDO.setDoctorName(doctorName);
						patientRemindRecordESDO.setCreateDate(new Date());
						patientRemindRecordESDO.setRemindType(1);
						if (flag) {
							patientRemindRecordESDO.setStatus(1);
							String update="UPDATE wlyy_child_immune_vaccin SET alert_tag=1,alert_time='"+DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"' where `code`='"+vaccinCode+"'";
							jdbcTemplate.update(update);
						}else {
							patientRemindRecordESDO.setStatus(0);
						}
						patientRemindRecordESDOList.add(patientRemindRecordESDO);
					}
				}
			}
		}
		//保存到es的提醒日志表中
		esSavePatientRemindRecord(patientRemindRecordESDOList);
		return 200;
	}
	public int alertImmVacclinByChildInfoCode(String alertDataJsonStr, String doctor)throws Exception{
		if (StringUtils.isEmpty(alertDataJsonStr)){
			return -1;
		}
		Doctor doctorObj = doctorDao.findByCode(doctor);
		String doctorName = "";
		String doctorLevel = "";
		if (doctorObj!=null){
			doctorName = doctorObj.getName();
			if (doctorObj.getLevel()==1) {
				doctorLevel="专科";
			}
			if (doctorObj.getLevel()==2) {
				doctorLevel="全科";
			}
			if (doctorObj.getLevel()==3){
				doctorLevel="健管";
			}
		}
		List<PatientRemindRecordESDO> patientRemindRecordESDOList = new ArrayList<>();
		JSONObject jsonObject = new JSONObject(alertDataJsonStr);
		String childCode = jsonObject.getString("childCode");
		String childName = jsonObject.getString("childName");
		String vaccinName = jsonObject.getString("vaccinName");
		String vaccinCode = jsonObject.getString("vaccinCode");
		String sql ="SELECT" +
				" cfi.relation," +
				" p.`code`," +
				" p.`name`," +
				" p.openid" +
				" FROM" +
				" wlyy_child_family_immune cfi" +
				" LEFT JOIN wlyy_patient p ON cfi.family_code = p.`code`" +
				" WHERE" +
				" cfi.child_code = '"+childCode+"'" +
				" AND cfi.del = 0 and (p.openid is not null or p.openid !='')";
		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
		if (list.size()==0){
			return -10000;
		}
		List<String> openIdList = new ArrayList<>();
		for (Map<String,Object> map : list){
			//如果父母亲都在就都发
			if (!openIdList.contains(String.valueOf(map.get("openid")))){
				if (("1".equals(String.valueOf(map.get("relation"))) || "2".equals(String.valueOf(map.get("relation")))) && StringUtils.isNotBlank(String.valueOf(map.get("openid")))){
					boolean flag =true;
					try {
						WechatTemplateConfig temp = templateConfigDao.findByScene("template_deal_with", "ymjztx");
						JSONObject json = new JSONObject();
						json.put("toUser",String.valueOf(map.get("code")));
						json.put("keyword1", temp.getKeyword1().replace("key1",DateUtil.dateToStr(new Date(), "yyyy-MM-dd")));
						json.put("keyword2", temp.getKeyword2().replace("key1", doctorName+"("+doctorLevel+")"));
						json.put("remark", temp.getRemark());
						json.put("first", temp.getFirst().replace("key1",String.valueOf(map.get("name"))).replace("key2", childName).replace("key3",vaccinName));
						logger.info("weiTempJOSN:"+json.toString());
						pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 24,String.valueOf(map.get("openid")) , String.valueOf(map.get("name")), json);
					}catch (Exception e){
						e.printStackTrace();
						flag = false;
					}
					//发送微信消息并且插入一条es提醒数据
					PatientRemindRecordESDO patientRemindRecordESDO =  new PatientRemindRecordESDO();
					patientRemindRecordESDO.setCode(getCode());
					patientRemindRecordESDO.setPatient(String.valueOf(map.get("code")));
					patientRemindRecordESDO.setPatientName(String.valueOf(map.get("name")));
					patientRemindRecordESDO.setDoctor(doctor);
					patientRemindRecordESDO.setDoctorName(doctorName);
					patientRemindRecordESDO.setCreateDate(new Date());
					patientRemindRecordESDO.setRemindType(1);
					if (flag) {
						patientRemindRecordESDO.setStatus(1);
						String update="UPDATE wlyy_child_immune_vaccin SET alert_tag=1,alert_time='"+DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"' where `code`='"+vaccinCode+"'";
						jdbcTemplate.update(update);
					}else {
						patientRemindRecordESDO.setStatus(0);
					}
					patientRemindRecordESDOList.add(patientRemindRecordESDO);
				}
			}
		}
		//保存到es的提醒日志表中
		esSavePatientRemindRecord(patientRemindRecordESDOList);
		return 200;
	}
	public boolean esSavePatientRemindRecord(List<PatientRemindRecordESDO> patientRemindRecordESDOList)throws Exception{
		JestClient jestClient = null;
		boolean flag = true;
		try {
			jestClient = elasticFactory.getJestClient();
			if(patientRemindRecordESDOList != null && patientRemindRecordESDOList.size()>0){
				flag = elastricSearchSave.save(patientRemindRecordESDOList, esIndex, esType);
			}
		}catch (Exception e){
			e.printStackTrace();
			flag = false;
		} finally{
			if (jestClient != null) {
				jestClient.shutdownClient();
			}
		}
		return  flag;
	}
	@Transactional(rollbackFor = Exception.class)
	public int getChildImmuneVaccinEveryDay()throws Exception{
		int result = 0;
		try {
			String sql ="SELECT" +
					" DISTINCT ci.`code`," +
					" ci.idcard," +
					" ci.`name`," +
					" ci.ssc," +
					" ci.barcode" +
					" FROM" +
					" wlyy_child_family_immune fi" +
					" LEFT JOIN wlyy_child_info ci ON fi.child_code = ci.`code`" +
					" WHERE" +
					" fi.del = 0";
			List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
			for (Map<String,Object> map : list){
				String barcode = String.valueOf(map.get("barcode"));
				System.out.println("===============barcode=============="+barcode);
				String deptStr = immuneService.findDept(barcode);
				if (StringUtils.isNotBlank(deptStr)){
					JSONObject jsonObject = new JSONObject(deptStr);
					if (jsonObject.getInt("status")==200) {
						JSONObject json = new JSONObject(jsonObject.getString("data"));
						JSONArray jsonArray = json.getJSONArray("body");
						for (int i = 0;i<jsonArray.length();i++){
							String deptNum  = jsonArray.getJSONObject(i).getString("deptNum");
							String vaccinStr = immuneService.findMyVaccin(barcode,deptNum);
							JSONObject vaccinJson = new JSONObject(vaccinStr);
							if (vaccinJson.getInt("status")==200) {
								JSONObject vaccinJson2 = new JSONObject(vaccinJson.getString("data"));
								JSONArray vaccinJsonJSONArray = vaccinJson2.getJSONArray("body");
								List<ChildImmuneVaccin> vaccinList = childImmuneVaccinDao.findByBarcode(barcode);
								//原来有的则不用新增,原来有的但是在返回回来的数据没有的话删除数据
								for (ChildImmuneVaccin childImmuneVaccin : vaccinList){
									int count = 0;
									for (int j=0;j<vaccinJsonJSONArray.length();j++){
										String ymbm = vaccinJsonJSONArray.getJSONObject(j).getString("ymBm");
										String jzzc = vaccinJsonJSONArray.getJSONObject(j).getString("jzZc");
										if (childImmuneVaccin.getYmbm().equals(ymbm) && childImmuneVaccin.getJzzc().equals(jzzc)){
											count++;
										}
									}
									//原来有的疫苗要判断是否有超过预约时间的7天,并且看提醒是否超过7天,超过7天可以重新提醒
									if (count>0 && childImmuneVaccin.getIsOut()==1){
										if (DateUtil.getPreDays(childImmuneVaccin.getJzrq(),7).before(new Date())){
											//过了预约时间7天,更新为isOut=0,则不能预约了
											childImmuneVaccinDao.updateIsOutByCode(childImmuneVaccin.getCode());
										}else {
											//判断是否过了7天提醒时间
											if (childImmuneVaccin.getAlert_tag()==1 && DateUtil.getPreDays(childImmuneVaccin.getAlert_time(),7).before(new Date())){
												childImmuneVaccinDao.updateAlertTagByCode(childImmuneVaccin.getCode(),0);
											}
										}
									}
									if (count==0){
										result+= childImmuneVaccinDao.updateDelByCode(childImmuneVaccin.getCode());
									}
								}
								//如果本地没有就是新增的
								List<ChildImmuneVaccin> vaccins = new ArrayList<>();
								for (int j=0;j<vaccinJsonJSONArray.length();j++){
									String ymbm = vaccinJsonJSONArray.getJSONObject(j).getString("ymBm");
									String jzzc = vaccinJsonJSONArray.getJSONObject(j).getString("jzZc");
									int count = 0;
									for (ChildImmuneVaccin childImmuneVaccin : vaccinList){
										if (childImmuneVaccin.getYmbm().equals(ymbm) && childImmuneVaccin.getJzzc().equals(jzzc)){
											count++;
										}
									}
									if (count==0){
										ChildImmuneVaccin childImmuneVaccin = new ChildImmuneVaccin();
										childImmuneVaccin.setCode(getUUID());
										childImmuneVaccin.setName(String.valueOf(map.get("name")));
										childImmuneVaccin.setIdcard(String.valueOf(map.get("idcard")));
										childImmuneVaccin.setSsc(String.valueOf(map.get("ssc")));
										childImmuneVaccin.setBarcode(barcode);
										childImmuneVaccin.setChildInfoCode(String.valueOf(map.get("code")));
										childImmuneVaccin.setYmkc(vaccinJsonJSONArray.getJSONObject(j).getString("ymkc"));
										childImmuneVaccin.setYmmc(vaccinJsonJSONArray.getJSONObject(j).getString("ymmc"));
										childImmuneVaccin.setYmkcsm(vaccinJsonJSONArray.getJSONObject(j).getString("ymkcsm"));
										childImmuneVaccin.setYmbm(ymbm);
										childImmuneVaccin.setJzzc(jzzc);
										childImmuneVaccin.setJzrq(DateUtil.strToDate(vaccinJsonJSONArray.getJSONObject(j).getString("jzRq"),DateUtil.YYYY_MM_DD));
										childImmuneVaccin.setAlert_tag(0);
										childImmuneVaccin.setDel(0);
										childImmuneVaccin.setCreate_time(new Date());
										if (DateUtil.getPreDays(DateUtil.strToDate(vaccinJsonJSONArray.getJSONObject(j).getString("jzRq")),7).before(new Date())){
											//过了预约时间7天,更新为isOut=0,则不能预约了
											childImmuneVaccin.setIsOut(0);
										}else {
											childImmuneVaccin.setIsOut(1);
										}
										vaccins.add(childImmuneVaccin);
										result++;
									}
								}
								childImmuneVaccinDao.save(vaccins);
							}
						}
					}
				}
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return result;
	}
	public int alertImmVacclinByDoctor(String doctor)throws Exception{
		List<Map<String, Object>> immVaccinList = getImmVaccinList(doctor,0,0,0);
		String alertJsonStr="";
		JSONArray jsonArray = new JSONArray();
		if (immVaccinList != null) {
			for (Map<String, Object> map : immVaccinList) {
				JSONObject jsonObject = new JSONObject();
				jsonObject.put("vaccinCode",map.get("code"));//待接种疫苗记录code
				jsonObject.put("childName", map.get("child_name"));//儿童姓名
				jsonObject.put("childCode", map.get("childCode"));//儿童code
				jsonObject.put("vaccinName", map.get("ymmc"));//疫苗名称
				jsonArray.put(jsonObject);
			}
		}
		alertJsonStr = jsonArray.toString();
		return alertImmVacclinByChildInfoCodes(alertJsonStr,doctor);
	}
}

+ 14 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -41,7 +41,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.annotation.Transient;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@ -372,6 +371,7 @@ public class JMJkEduArticleService extends BaseService {
        Set<String> openidSet = getOpenid(patientSet);
        List<HealthEduArticleES> healthEduArticleESList = new ArrayList<>();
        List<HealthEduArticleES> healthEduArticleESList2 = new ArrayList<>();
        Doctor doctor = doctorDao.findByCode(sendCode);
        AdminTeam adminTeam =null;
        if(teamId!=null){
@ -404,12 +404,14 @@ public class JMJkEduArticleService extends BaseService {
        }
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"","");
        Date createTime = new Date();
        Set<String> openidSetTemp = new HashSet<>();
        for (String patient : patientSet) {
            one = patientDao.findByCode(patient);
            if(one==null){
                continue;
            }
            HealthEduArticleES healthEduArticleES = new HealthEduArticleES();
            healthEduArticleES.setDoctorCode(doctor.getCode());
            healthEduArticleES.setDoctorName(doctor.getName());
@ -474,7 +476,10 @@ public class JMJkEduArticleService extends BaseService {
            healthEduArticleES.setUserType(1);
            healthEduArticleES.setOpenidSet(openidSet);
            healthEduArticleESList.add(healthEduArticleES);
            if(!openidSetTemp.contains(one.getOpenid())){
                openidSetTemp.add(one.getOpenid());
                healthEduArticleESList2.add(healthEduArticleES);
            }
        }
        if(healthEduArticleESList.size()>0){
@ -489,7 +494,7 @@ public class JMJkEduArticleService extends BaseService {
            elastricSearchSave.save(e, esIndex, esType);
            thirdJkEduArticleService.saveBehavior(articleId,doctor.getCode(),7,patientSet.size());
        }
        return healthEduArticleESList;
        return healthEduArticleESList2;
    }
    public JSONObject pushArticleConfirm(String articleId, String labelUnit, String labelSex, String labelServe, String labelDisease, String labelHealth,String userCode,String currentUserRole, String currentUserRoleLevel) throws Exception {
        JSONObject article = thirdJkEduArticleService.getArticalById(articleId,"","");
@ -516,7 +521,7 @@ public class JMJkEduArticleService extends BaseService {
        //全选的时候前端传0,后台要去数据库再查询一次
        String tableSql = " select p.code from wlyy_sign_family w ,wlyy_admin_team t, dm_hospital h  ";
        String whereSql = " where w.status>0  and w.admin_team_code=t.id and t.org_code=h.code ";
        String whereSql = " where w.status>0 and w.expenses_status=1 and w.admin_team_code=t.id and t.org_code=h.code ";
        //通过登录的角色区域权限 限制所属患者条件
@ -594,7 +599,6 @@ public class JMJkEduArticleService extends BaseService {
            }
            groupPatient = jdbcTemplate.queryForList(sql, String.class);
        }else{
            groupPatient = jdbcTemplate.queryForList(tableSql + whereSql, String.class);
        }
        patientSet.addAll(groupPatient);
@ -1492,14 +1496,17 @@ public class JMJkEduArticleService extends BaseService {
//    }
    public Set<String> getOpenid(Set<String> patientSet){
        Set<String> openidSet = new HashSet<>(patientSet);
        Set<String> openidSet = new HashSet<>();
        Patient one = null;
        for (String patient : patientSet) {
            one = patientDao.findByCode(patient);
            if(one==null){
                continue;
            }
            openidSet.add(one.getOpenid());
            if(one.getOpenid()!=null){
                openidSet.add(one.getOpenid());
            }
        }
        return openidSet;
    }

+ 23 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java

@ -183,10 +183,10 @@ public class SpecialistEvaluateSevice extends BaseService {
    }
    /**
     * 发送消息 type:19 受理提醒,20 待办工作提醒 21 服务进展提醒-已完成 22 服务进展提醒-未完成 23 服务进展提醒-待完成
     * 发送消息 type:19 受理提醒,20 待办工作提醒 21 服务进展提醒-已完成 22 服务进展提醒-未完成 23 服务进展提醒-待完成 24 收到协同任务 25 在线助手已接收 26 在线助手已退回 27 协同服务已完成
     */
    public JSONObject sendMessage(Message message,String hospitalCode,String patientCode,Integer num){
    public JSONObject sendMessage(Message message,String hospitalCode,String patientCode,Integer num,JSONObject jsonObject){
        JSONObject object = new JSONObject();
        try {
            Hospital hospital = null;
@ -225,6 +225,26 @@ public class SpecialistEvaluateSevice extends BaseService {
                message.setType(23);
                message.setTitle("康复计划-服务进展提醒");
                message.setContent("您的"+patient.getName()+"签约居民今日有"+num+"个康复计划项目待完成,请尽快处理");
            }else if (message.getType() == 24){
                message.setOver("1");
                message.setType(24);
                message.setTitle("收到协同任务");
                message.setContent("您接收到“"+jsonObject.getString("type")+"”协同服务:"+jsonObject.getString("content").substring(0,19));
            }else if (message.getType() == 25){
                message.setOver("1");
                message.setType(25);
                message.setTitle("在线助手已接收");
                message.setContent("您发起的“"+jsonObject.getString("type")+"”协同服务,已被在线助手接收,负责人:"+jsonObject.getString("customerName")+",联系方式:"+jsonObject.getString("phone")+"。");
            }else if (message.getType() == 26){
                message.setOver("1");
                message.setType(26);
                message.setTitle("在线助手已退回");
                message.setContent("您发起的“"+jsonObject.getString("type")+"”协同服务,已被在线助手退回。原因:"+jsonObject.getString("returnedRemark"));
            }else if (message.getType() == 27){
                message.setOver("1");
                message.setType(27);
                message.setTitle("协同服务已完成");
                message.setContent("您发起的“"+jsonObject.getString("type")+"”协同服务,已完成。");
            }
            message.setCode(getCode());
//            message.setSenderName(sendDoctor.getName());
@ -247,4 +267,5 @@ public class SpecialistEvaluateSevice extends BaseService {
        return object;
    }
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistScreenResultService.java

@ -82,7 +82,7 @@ public class SpecialistScreenResultService extends BaseService {
        param.put("pageSize", size);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getScreenResult", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
        if ("success".equals(rs.getString("message"))) {
            return  rs.getJSONArray("detailModelList");
        }
        return null;
@ -95,7 +95,7 @@ public class SpecialistScreenResultService extends BaseService {
        param.put("doctor", doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getScreenCount", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
        if ("success".equals(rs.getString("message"))) {
            jsonObject =  rs.getJSONObject("obj");
            return  jsonObject;
        }

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/rehabilitation/RehabilitationManageService.java

@ -629,7 +629,7 @@ public class RehabilitationManageService extends BaseService {
            message.setSender(patient);
            message.setReceiver(doctor);
            message.setRelationCode(planDetailId);
            specialistEvaluateSevice.sendMessage(message,hospotal,patient,null);
            specialistEvaluateSevice.sendMessage(message,hospotal,patient,null,null);
            //发送微信模板消息
            int evaluation = object.getInt("evaluation");
            if (evaluation == 1){
@ -703,7 +703,7 @@ public class RehabilitationManageService extends BaseService {
            message1.setType(type);
            message1.setReceiver(doctor);
            message1.setRelationCode(planDetailIds);
            specialistEvaluateSevice.sendMessage(message1,null,patient,num);
            specialistEvaluateSevice.sendMessage(message1,null,patient,num,null);
        }
    }
@ -802,7 +802,7 @@ public class RehabilitationManageService extends BaseService {
            message1.setType(type);
            message1.setReceiver(doctor);
            message1.setRelationCode(planDetailIds);
            specialistEvaluateSevice.sendMessage(message1,hospital,patient,num);
            specialistEvaluateSevice.sendMessage(message1,hospital,patient,num,null);
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/rehabilitation/RehabilitationPlanService.java

@ -162,7 +162,7 @@ public class RehabilitationPlanService extends BaseService {
                    message.setType(19);
                    message.setRelationCode(detail.getString("planId"));
                    message.setReceiver(detail.getString("doctor"));
                    specialistEvaluateSevice.sendMessage(message, detail.getString("hospital"), patient, null);
                    specialistEvaluateSevice.sendMessage(message, detail.getString("hospital"), patient, null,null);
                }
            }
            return rs.getString("message");

+ 155 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java

@ -3,17 +3,22 @@ package com.yihu.wlyy.service.survey;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.survey.*;
import com.yihu.wlyy.entity.manage.User;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.manage.UserDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
@ -21,6 +26,7 @@ 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.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@ -39,6 +45,9 @@ import java.util.*;
@Transactional
public class ManagerQuestionnaireService extends BaseService {
    @Value("${customerService.url}")
    private String customerUrl;
    @Autowired
    private SurveyDao surveyDao;
    @Autowired
@ -88,7 +97,11 @@ public class ManagerQuestionnaireService extends BaseService {
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    private DoctorService doctorService;
    @Autowired
    private UserDao userDao;
    @Autowired
    private SurveyQuestionResultDao questionResultDao;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -100,7 +113,7 @@ public class ManagerQuestionnaireService extends BaseService {
        String surveyComment = jsonStr.getString("comment");
        String templateCode = null;
        String send = jsonStr.get("send").toString();
        String templateLabel = jsonStr.getString("label");
        //String templateLabel = jsonStr.getString("label");
        int status = 1;
//        自主创建
        int useType = 1;
@ -1078,6 +1091,9 @@ public class ManagerQuestionnaireService extends BaseService {
                        case 4:
                            tags[i] = "生活日常";
                            break;
                        case 5:
                            tags[i] = "评分筛查";
                            break;
                    }
                }
@ -1130,6 +1146,9 @@ public class ManagerQuestionnaireService extends BaseService {
                        case 4:
                            tags[i] = "生活日常";
                            break;
                        case 5:
                            tags[i] = "评分筛查";
                            break;
                    }
                }
                map.put("title", title);
@ -1809,4 +1828,137 @@ public class ManagerQuestionnaireService extends BaseService {
        //更改调查对象表答题状态为已答
        //surveyUserDao.modifyStatus(surveyCode, patient);
    }
    //查询出推送居民
    public List<Map<String, Object>> initPatient(String labelUnitType, String labelSexType, String labelServerType, String labelDiseaseType, String labelHealthType, String currentUserRole, String currentUserRoleLevel) {
        String tableSql = " select p.code as servicePatientCode ,w.`name` as servicePatientName,w.ssc,w.idcard,w.mobile,w.hospital,w.hospital_name as hospitalName, h.town,h.town_name as townName from wlyy_sign_family w ,wlyy_admin_team t, dm_hospital h  ";
        String whereSql = " where w.status>0 and w.expenses_status=1 and w.admin_team_code=t.id and t.org_code=h.code ";
        //通过登录的角色区域权限 限制所属患者条件
        if (StringUtils.isNotBlank(labelUnitType)) {
            switch (currentUserRoleLevel) {
                case "1": {
                    whereSql += " and h.city in (" + labelUnitType + ")";
                    break;
                }
                case "2": {
                    whereSql += " and h.town in (" + labelUnitType + ")";
                    break;
                }
                case "3": {
                    whereSql += " and h.code in (" + labelUnitType + ")";
                    break;
                }
            }
        } else {
            switch (currentUserRoleLevel) {
                case "1": {
                    whereSql += " and h.province = '" + currentUserRole + "'";
                    break;
                }
                case "2": {
                    whereSql += " and h.city = '" + currentUserRole + "'";
                    break;
                }
                case "3": {
                    whereSql += " and h.town = '" + currentUserRole + "'";
                    break;
                }
                case "4": {
                    whereSql += " and h.code = '" + currentUserRole + "'";
                    break;
                }
            }
        }
        if (StringUtils.isNotBlank(labelServerType)) {
            tableSql += " , wlyy_sign_family_server s   ";
            whereSql += " and s.server_type in (" + labelServerType + " ) and w.code= s.sign_code";
        }
        tableSql += " , wlyy_patient p  ";
        whereSql += " and p.code=w.patient AND p.openid IS NOT NULL and p.openid <>'' ";
        if (StringUtils.isNotBlank(labelSexType)) {
            whereSql += " and p.sex in (" + labelSexType + ") ";
        }
        List<Map<String, Object>> groupPatient = null;
        if (StringUtils.isNotBlank(labelHealthType) || StringUtils.isNotBlank(labelDiseaseType)) {
            String sql = "SELECT DISTINCT s.patient as service_patient_code, f.`name` as service_patient_name, f.ssc,f.idcard,f.mobile,f.hospital,f.hospital_name,h.town,h.town_name  FROM ( SELECT t.patient," +
                    " GROUP_CONCAT(',',t.label_type,t.label,',') label FROM " +
                    " wlyy_sign_patient_label_info t WHERE t.patient IN (" +
                    tableSql + whereSql + ") AND t. STATUS = 1 GROUP BY t.patient ) s LEFT JOIN wlyy_sign_family f on s.patient=f.patient LEFT JOIN dm_hospital h on f.hospital=h.`code` where 1=1 ";
            if (StringUtils.isNotBlank(labelHealthType)) {
                String[] aa = labelHealthType.split(",");
                String bb = "";
                for (String a : aa) {
                    bb += " OR s.label LIKE '%,2" + a + ",%'";
                }
                sql += " AND ( " + bb.substring(3) + " )";
            }
            if (StringUtils.isNotBlank(labelDiseaseType)) {
                String[] aa = labelDiseaseType.split(",");
                String bb = "";
                for (String a : aa) {
                    bb += " OR s.label LIKE '%,3" + a + ",%'";
                }
                sql += " AND ( " + bb.substring(3) + " )";
            }
            sql += "and f.status>0 and f.expenses_status=1";
            groupPatient = jdbcTemplate.queryForList(sql);
        } else {
            groupPatient = jdbcTemplate.queryForList(tableSql + whereSql);
        }
        return groupPatient;
    }
    /**
     * 调用集美客服派发问卷协同服务接口
     * @param jsonData
     * @param patientInfo
     * @param doctor
     * @return
     * @throws Exception
     */
    public String createWorkOrder(String jsonData, List<Map<String, Object>> patientInfo, String doctor) throws Exception{
        JSONObject object = new JSONObject(jsonData);
        Doctor d = doctorService.findDoctorByCode(doctor);
        object.put("createUser", d.getCode());
        object.put("createUserName", d.getName());
        object.put("createUserType", 1);
        Map<String, Object> param = new HashedMap();
        param.put("patientInfo", patientInfo.toString());
        param.put("jsonData", object.toString());
        HttpResponse response = null;
        response = HttpUtils.doPost(customerUrl + "synergy/questionnaire/createWorkOrder", param);
        JSONObject rs = new JSONObject(response.getContent());
        return rs.getString("data");
    }
    /**
     * 保存问卷调查结果和答案
     * @param jsonData
     * @param patientCode
     * @param customerCode
     * @return
     * @throws Exception
     */
    public String saveQuestionResultAndAnswer(JSONObject jsonData, String patientCode, String customerCode) throws Exception {
        String surveyCode = jsonData.get("surveyCode").toString();
        SurveyTemplates templates = surveyTemplatesDao.findById(surveyCode);
        Patient patient = patientDao.findByCode(patientCode);
        User user = userDao.findByCode(customerCode);
        SurveyQuestionResult questionResult =  new SurveyQuestionResult();
        String code = getCode();
        questionResult.setCode(code);
        questionResult.setTemplateCode(templates.getCode());
        questionResult.setTemplateTitle(templates.getTitle());
        questionResult.setPatientCode(patient.getCode());
        questionResult.setPatientName(patient.getName());
        questionResult.setType(1);
        questionResult.setCreateUser(customerCode);
        questionResult.setCreateUserName(user.getName());
        questionResult.setCreateTime(new Date());
        questionResultDao.save(questionResult);
        this.saveAnswer(patientCode, code, jsonData);
        return code;
    }
}

+ 172 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/synergy/SynergyManageService.java

@ -0,0 +1,172 @@
package com.yihu.wlyy.service.synergy;
import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
 * Created by humingfen on 2018/10/9.
 */
@Service
@Transactional
public class SynergyManageService extends BaseService {
    @Value("${customerService.url}")
    private String customerUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private FollowUpDao followUpDao;
    @Autowired
    private HospitalDao hospitalDao;
    public JSONObject getWorkOrderInfo(String workorderCode, String patient, Integer role) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("workorderCode", workorderCode);
        param.put("patient", patient);
        param.put("role", role);
        HttpResponse response = null;
        response = HttpUtils.doPost(customerUrl + "synergy/customer/getWorkOrderInfo", param);
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public String createWorkorder(String doctor, Set<String> patientSet, Integer type, String objectId, String serviceDate, Integer priority, String remark, String followupClass, String followupType){
        String response = null;
        JSONArray array = new JSONArray();
        String patientCode1 = null;
        Doctor doctor1 = doctorDao.findByCode(doctor);
        for (String patientCode:patientSet){
            if (patientSet.size() == 1){
                patientCode1 = patientCode;
            }
            Patient patient = patientDao.findByCode(patientCode);
            com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
            object.put("servicePatientCode",patient.getCode());
            object.put("servicePatientName",patient.getName());
            object.put("ssc",patient.getSsc());
            object.put("idcard",patient.getIdcard());
            object.put("mobile",patient.getMobile());
            object.put("hospital",doctor1.getHospital());
            object.put("hospitalName",doctor1.getHospitalName());
            Hospital hospital = hospitalDao.findByCode(doctor1.getHospital());
            object.put("town", hospital.getTown());
            object.put("townName",hospital.getTownName());
            array.add(object);
        }
        com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
        object.put("type",type);
        object.put("serviceTime",serviceDate);
        object.put("priority",priority);
        object.put("createUser",doctor1.getCode());
        object.put("createUserName",doctor1.getName());
        object.put("hospital",doctor1.getHospital());
        object.put("hospitalName",doctor1.getHospitalName());
        object.put("createUserType",1);
        object.put("remark",remark);
        if (type == 3){
            Followup followup = new Followup();
            followup.setDoctorCode(doctor1.getCode());
            followup.setDoctorName(doctor1.getName());
            if (patientCode1 != null){
                Patient patient1 = patientDao.findByCode(patientCode1);
                followup.setPatientCode(patient1.getCode());
                followup.setPatientName(patient1.getName());
                followup.setIdcard(patient1.getIdcard());
                SignFamily signFamily = signFamilyDao.findByPatient(patientCode1);
                followup.setAdminTeamCode(signFamily.getAdminTeamId());
                followup.setSignType(Integer.parseInt(signFamily.getSignType()));
                followup.setSignCode(signFamily.getCode());
            }
            followup.setFollowupDate(DateUtil.strToDate(serviceDate));
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
            followup.setOrgCode(doctor1.getHospital());
            followup.setOrgName(doctor1.getHospitalName());
            followup.setDataFrom("2");
            followup.setStatus("2");
            followup.setCreater(doctor1.getCode());
            followup.setCreateTime(new Date());
            followup = followUpDao.save(followup);
            object.put("relationCode",followup.getId());
            object.put("relationCodeName","随访");
        }else if (type == 1){
            object.put("relationCode",objectId);
            object.put("relationCodeName","健康教育");
        }else if (type == 5){
            object.put("relationCode",objectId);
            object.put("relationCodeName","疾病筛查");
        }
        String url = customerUrl + "followup/saveFollowupProjectData";
        Map<String, String> params = new HashMap<>();
        params.put("servicers",array.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }
    public JSONObject workorderList(String userCode,Integer workorderType,Integer status,String serviceStartTime,String serviceEndTime,Integer isAcceptTask,Integer page,Integer pageSize) throws Exception{
        Map<String, Object> param = new HashedMap();
        param.put("userCode",userCode);
        param.put("workorderType",workorderType);
        param.put("status",status);
        param.put("serviceStartTime",serviceStartTime);
        param.put("serviceEndTime",serviceEndTime);
        param.put("isAcceptTask",isAcceptTask);
        param.put("page",page);
        param.put("pageSize",pageSize);
        HttpResponse response = HttpUtils.doGet(customerUrl + "/doctor/synergy/workorderList", param);
        JSONObject result = new JSONObject(response.getContent());
        if(result.getInt("status")==200){
            JSONObject json = result.getJSONObject("data");
            return json;
        }
        throw new Exception("请求客服系统服务失败!");
    }
    public void reminder(String userCode,String workorderCode) throws Exception{
        Map<String, Object> param = new HashedMap();
        param.put("userCode",userCode);
        param.put("workorderCode",workorderCode);
        HttpResponse response = HttpUtils.doPost(customerUrl + "/doctor/synergy/reminder", param);
        JSONObject result = new JSONObject(response.getContent());
        if(result.getInt("status")!=200){
            throw new Exception("请求客服系统服务失败!");
        }
    }
}

+ 18 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/ImmuneService.java

@ -767,13 +767,28 @@ public class ImmuneService {
	 * @return
	 * @throws Exception
	 */
	public String findWzymBymykh(String barcode) throws Exception{
		String url = jwUrl + "/third/jm/imm/findWzymBymykh";
	public String findYzymBymykh(String barcode) throws Exception{
		String url = jwUrl + "/third/jm/imm/findYzymBymykh";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("barCode", barcode));
		params.add(new BasicNameValuePair("etmykh", barcode));
		String response = httpClientUtil.post(url, params, "UTF-8");
		return response;
	}
	public String findMyVaccin(String barcode,String deptNum) throws Exception{
		String url = jwUrl + "/third/jm/imm/findMyVaccin";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("deptNum", deptNum));
		params.add(new BasicNameValuePair("etmykh", barcode));
		String response = httpClientUtil.post(url, params, "UTF-8");
		return response;
	}
	public String findDept(String barcode) throws Exception{
		String url = jwUrl + "/third/jm/imm/findDept";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("etmykh", barcode));
		String response = httpClientUtil.post(url, params, "UTF-8");
		return response;
	}
}

+ 3 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/WeiXinCoreService.java

@ -1,9 +1,6 @@
package com.yihu.wlyy.service.weixin;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.process.WeiXinEventProcess;
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
import org.dom4j.Document;
@ -11,8 +8,6 @@ import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,8 +15,6 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -42,13 +35,13 @@ public class WeiXinCoreService extends BaseService {
     * @param accessToken
     */
    public String messageProcess(HttpServletRequest request, String accessToken) {
        try {
        try (InputStream inputStream = request.getInputStream()){
            String returnStr = "";
            // 将解析结果存储在HashMap中
            Map<String, String> message = new HashMap();
            // 从request中取得输入流
            InputStream inputStream = request.getInputStream();
            // 读取输入流
            SAXReader reader = new SAXReader();
            Document document = reader.read(inputStream);
@ -62,9 +55,7 @@ public class WeiXinCoreService extends BaseService {
                Element ele = (Element) e;
                message.put(ele.getName(), ele.getText());
            }
            logger.info("weixin  event:" + message.toString());
            // 释放资源
            inputStream.close();
//            logger.info("weixin  event:" + message.toString());
            // 添加access_token参数
            message.put("token", accessToken);
            // 消息处理

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

@ -421,9 +421,9 @@ public class PushMsgTask {
            String temp_id = "";
            if (type == 3) {
                if (json.has("isPublic") && json.getInt("isPublic") == 1) {
                    temp.setUrl(url + "jbsq/html/public-consult-detail.html?openid=" + openid + "&code=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(url + "jbsq/html/public-consult-detail.html?openid=" + openid + "&code=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                } else {
                    temp.setUrl(url + "yszx/html/consulting-doctor.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(url + "yszx/html/consulting-doctor.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                }
                temp_id = template_consult_notice;
                temp.setTemplate_id(temp_id);
@ -458,7 +458,7 @@ public class PushMsgTask {
                } else {
                    if (json.has("agent") && ("1".equals(json.getString("agent")))) {
//                        发送给授权代理人
                        temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + json.getString("represented") + "&signCode=" + json.getString("signCode"));
                        temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):"") + "&signCode=" + json.getString("signCode"));
                    } else if (json.has("agent") && ("0".equals(json.getString("agent")))) {
//                        发送给自己
                        temp.setUrl(url + "qygl/html/pay_flow.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + json.getString("represented") + "&signCode=" + json.getString("signCode"));
@ -484,7 +484,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("content"));
                m.put("keyword4", keyword4);
            } else if (type == 4) {
                temp.setUrl(url + "yszd/html/guidance-detail.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&id=" + String.valueOf(json.get("id")) + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "yszd/html/guidance-detail.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&id=" + String.valueOf(json.get("id")) + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_health_notice;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -508,7 +508,7 @@ public class PushMsgTask {
                keyword5.setValue(json.getString("content"));
                m.put("keyword5", keyword5);
            } else if (type == 5) {
                temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "ssgg/html/doctor-homepage-new.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_termination;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -528,7 +528,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("date"));
                m.put("keyword4", keyword4);
            } else if (type == 6) {
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid + "&orgCode=" + json.get("orgCode") + "&id=" + json.getString("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "wdyy/html/detail-appointment.html?openid=" + openid + "&orgCode=" + json.get("orgCode") + "&id=" + json.getString("id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_appoint_success;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -548,7 +548,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("date"));
                m.put("planstarttime", keyword4);
            } else if (type == 7) {
                temp.setUrl(url + "wdyy/html/my-appointment.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "wdyy/html/my-appointment.html?openid=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_appoint_failed;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -588,7 +588,7 @@ public class PushMsgTask {
                keyword4.setValue(json.getString("content"));
                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"));
                temp.setUrl(url + "jkjy/html/article.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp_id = template_healthy_article;
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -615,7 +615,7 @@ public class PushMsgTask {
                if (json.has("url")) {
                    temp.setUrl(url + json.getString("url"));
                } else {
                    temp.setUrl(url + "qygl/html/signing-doctors.html?openid=" + openid + "&state=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                    temp.setUrl(url + "qygl/html/signing-doctors.html?openid=" + openid + "&state=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                }
                temp.setTemplate_id(template_doctor_change);
                WechatTemplateData keyword1 = new WechatTemplateData();
@ -636,7 +636,7 @@ public class PushMsgTask {
                if (json.has("url")) {
                    temp.setUrl(url + json.getString("url"));
                } else {
                    String xinurl = url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&survey_id=" + json.getString("survey_id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented");
                    String xinurl = url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&survey_id=" + json.getString("survey_id") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):"");
//                temp.setUrl(url + "survey/html/survey_info.html?openid=" + openid + "&state=" + openid + "&survey_id=" + json.getString("survey_id") + "&toUser=" + json.getString("toUser") + "&toName=" + name);
                    temp.setUrl(xinurl);
                }
@ -719,7 +719,7 @@ public class PushMsgTask {
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
            } else if (type == 16) {
                temp.setUrl(url + "xuqian/html/information.html?openid=" + openid + "&changeDoctor=" + 1 + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "xuqian/html/information.html?openid=" + openid + "&changeDoctor=" + 1 + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp.setTemplate_id(template_doctor_survey);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
@ -730,7 +730,7 @@ public class PushMsgTask {
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            } else if (type == 17) {
                temp.setUrl(url + "yszx/html/manyidu.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "yszx/html/manyidu.html?openid=" + openid + "&consult=" + json.getString("consult") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):""));
                temp.setTemplate_id(template_doctor_survey);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
@ -781,7 +781,9 @@ public class PushMsgTask {
                keyword3.setColor("#000000");
                keyword3.setValue(json.getString("keyword3"));
                m.put("keyword3", keyword3);
            }else if (type == 21) {
            }
            //@TODO 以后需要了释放出来 要做易联众对接支付消息
            /*else if (type == 21) {
                if (json.has("url")) {
                    temp.setUrl(url + json.getString("url"));
                }
@ -806,7 +808,7 @@ public class PushMsgTask {
                keyword5.setColor("#000000");
                keyword5.setValue(json.getString("keyword5"));
                m.put("keyword5", keyword5);
            }else if (type == 22) {//设备绑定
            }*/else if (type == 22) {//设备绑定
                if (json.has("url")) {
                    temp.setUrl(url + json.getString("url"));
                }
@ -851,7 +853,7 @@ public class PushMsgTask {
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }else if (type==25){
                temp.setUrl(url + "kfgl/html/plan-item-detail.html?openid=" + openid + "&planIds=" + json.getString("planIds") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented")+"&doctor="+json.getString("doctor"));
                temp.setUrl(url + "kfgl/html/plan-item-detail.html?openid=" + openid + "&planIds=" + json.getString("planIds") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + (StringUtils.isNotEmpty(json.getString("represented"))?json.getString("represented"):"")+"&doctor="+json.getString("doctor"));
                temp.setTemplate_id(template_doctor_service);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");

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

@ -339,6 +339,8 @@ public class WechatController extends WeixinBaseController {
            if (!"undefined".equals(openid) && StringUtils.isNotBlank(openid)) {
                patient.setOpenid(openid);
                patient.setOpenidTime(new Date());
            }else{
            }
//            if (!org.springframework.util.StringUtils.isEmpty(openid)) {
//                patient.setOpenid(openid);
@ -424,8 +426,8 @@ public class WechatController extends WeixinBaseController {
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (StringUtils.isEmpty(openid)) {
                    errorMessage = "无效的OpenID!";
                } else if (StringUtils.isEmpty(openid)||"undefined".equals(openid)||openid.length()<10) {
                    errorMessage = "获取验证信息失败!";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);

+ 23 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -1,9 +1,7 @@
package com.yihu.wlyy.web.data;
import com.alibaba.fastjson.JSON;
import com.yihu.device.entity.DeviceDetail;
import com.yihu.es.entity.HealthEduArticleES;
//import com.yihu.es.entity.MapDataDTO;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientDeviceLog;
@ -19,31 +17,26 @@ import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientDeviceLogDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.device.DeviceDetailService;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.health.bank.CreditLogService;
import com.yihu.wlyy.service.app.health.bank.TaskService;
import com.yihu.wlyy.util.*;
import net.sf.json.JSONArray;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringEscapeUtils;
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.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
//import com.yihu.es.entity.MapDataDTO;
/**
 * Created by Administrator on 2016.10.17.
 */
@ -823,4 +816,25 @@ public class DataHandingService {
        sqlStr = sqlList.toArray(sqlStr);
        jdbcTemplate.batchUpdate(sqlStr);
    }
    /**
     * 24H干预指导率数据清洗
     */
    @Transactional(rollbackFor = Exception.class)
    public void abnormalSignRinse() throws Exception {
        String sql = " select i.* from device.wlyy_patient_health_index i where i.manage_result=2 and i.czrq>='2018-07-01 00:00:00' order by id desc ";
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql);
        Date czrq = null;
        Date record_date = null;
        long h24 = 1000 * 60 * 60 * 24 + 10;
        String tempSql = "";
        for (Map<String, Object> one : resultList) {
            czrq = (Date) one.get("czrq");
            record_date = (Date) one.get("record_date");
            if (czrq.getTime() - record_date.getTime() <= h24) {
                tempSql = "update device.wlyy_patient_health_index set manage_result=1 where id=" + one.get("id");
                jdbcTemplate.execute(tempSql);
            }
        }
    }
}

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -403,4 +403,18 @@ public class DataHandlingController extends BaseController {
            return write(-1,"清洗数据失败!");
        }
    }
    @RequestMapping(value = "/abnormalSignRinse",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("24H干预指导率数据清洗")
    public String abnormalSignRinse(){
        try{
            dataHandingService.abnormalSignRinse();
            return write(200,"清洗数据成功");
        }catch (Exception e){
            System.out.println(e.getMessage());
            e.printStackTrace();
            return write(-1,"清洗数据失败!");
        }
    }
}

+ 67 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java

@ -97,13 +97,15 @@ public class DoctorImmController extends BaseController {
				doctorCode = getUID();
			}
			
			List<Map<String, Object>> immrs = childFamilyImmuneService.getImmVaccinList(doctorCode,Integer.valueOf(pageNo),Integer.valueOf(pageSize));
			List<Map<String, Object>> immrs = childFamilyImmuneService.getImmVaccinList(doctorCode,Integer.valueOf(pageNo),Integer.valueOf(pageSize),1);
			JSONArray jsonArray = new JSONArray();
			if (immrs != null) {
				for (Map<String, Object> map : immrs) {
					JSONObject json = new JSONObject();
					json.put("vaccin_code",map.get("code"));
					json.put("family_name", map.get("family_name"));//关联居民
					json.put("child_name", map.get("child_name"));//儿童姓名
					json.put("child_code",map.get("childCode"));//儿童信息code
					json.put("birthday", map.get("birthday"));//儿童生日
					json.put("ymmc", map.get("ymmc"));//疫苗名称
					json.put("ymkc", map.get("ymkc"));//true:可约,false:不可约
@ -128,7 +130,13 @@ public class DoctorImmController extends BaseController {
	public String alertImmVacclinByDoctor(@ApiParam(name = "doctorcode", value = "医生CODE", defaultValue = "")
	                                      @RequestParam(value = "doctorcode", required = true) String doctorcode){
		try {
			// TODO: 2018/6/21
			int result = childFamilyImmuneService.alertImmVacclinByDoctor(doctorcode);
			if (result==-1){
				return error(-1, "参数错误!");
			}
			if (result==-10000){
				return error(-1, "该儿童父母数据为空,请联系管理员!");
			}
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
@ -148,21 +156,52 @@ public class DoctorImmController extends BaseController {
			return error(-1, "查询失败");
		}
	}
	@RequestMapping(value = "/alertImmVacclinByChildInfoCodes", method = RequestMethod.POST)
	@ApiOperation(value = "医生提醒居民疫苗接种")
	public String alertImmVacclinByChildInfoCodes(@ApiParam(name = "alertDataJsonStr", value = "[{\"childCode\":\"123\",\"childName\":\"张三\",\"vaccinCode\":\"asd123\",\"vaccinName\":\"疫苗名称\"}]", defaultValue = "")
										   @RequestParam(value = "alertDataJsonStr", required = true) String alertDataJsonStr){
		try {
			childFamilyImmuneService.alertImmVacclinByChildInfoCodes(alertDataJsonStr,getUID());
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	@RequestMapping(value = "/alertImmVacclinByChildInfoCode", method = RequestMethod.POST)
	@ApiOperation(value = "医生提醒居民疫苗接种")
	public String alertImmVacclinByChildInfoCode(@ApiParam(name = "alertDataJsonStr", value = "{\"childCode\":\"123\",\"childName\":\"张三\",\"vaccinCode\":\"asd123\",\"vaccinName\":\"疫苗名称\"}", defaultValue = "")
												  @RequestParam(value = "alertDataJsonStr", required = true) String alertDataJsonStr){
		try {
			int result = childFamilyImmuneService.alertImmVacclinByChildInfoCode(alertDataJsonStr,getUID());
			if (result==-1){
				return error(-1, "参数错误!");
			}
			if (result==-10000){
				return error(-1, "该儿童父母数据为空,请联系管理员!");
			}
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	
	@RequestMapping(value = "/getPatientImmVacclin", method = RequestMethod.GET)
	@ApiOperation(value = "根据儿童免疫条码获取待接种疫苗")
	public String getPatientImmVacclin(@ApiParam(name = "barcode", value = "儿童免疫编码", defaultValue = "")
	                                       @RequestParam(value = "barcode", required = true) String barcode){
		try {
			ChildImmuneVaccin childImmuneVaccin = childFamilyImmuneService.getChildImmuneVaccinByBarcode(barcode);
			return write(200, "请求成功","data",childImmuneVaccin);
			return write(200, "请求成功","data",childFamilyImmuneService.getChildImmuneVaccinByBarcode(barcode));
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	@RequestMapping(value = "/imm/findWzymBymykh", method = RequestMethod.GET)
	@RequestMapping(value = "/imm/findYzymBymykh", method = RequestMethod.GET)
	@ResponseBody
	@ObserverRequired
	@ApiOperation("计免:获取计划免疫接种记录")
@ -170,12 +209,32 @@ public class DoctorImmController extends BaseController {
								  @RequestParam(value = "barCode", required = true) String barCode){
		try{
			String re = immuneService.findWzymBymykh(barCode);
			return write(200, "查询成功","data",re);
			String re = immuneService.findYzymBymykh(barCode);
			JSONObject jsonObject = new JSONObject(re);
			if (jsonObject.getInt("status")==200){
				JSONObject json = new JSONObject(jsonObject.getString("data"));
				return write(200, "查询成功","data",json.getJSONArray("body"));
			}else {
				return error(-1,jsonObject.getString("error")+"--"+jsonObject.getString("message") );
			}
		}catch (Exception e){
			error(e);
			return error(-1, e.getMessage());
		}
	}
	@RequestMapping(value = "/imm/getChildImmuneVaccinEveryDay", method = RequestMethod.GET)
	@ResponseBody
	@ObserverRequired
	@ApiOperation("每天获取可预约疫苗test")
	public String getChildImmuneVaccinEveryDay (){
		try{
			int res = childFamilyImmuneService.getChildImmuneVaccinEveryDay();
			return write(200,"获取成功!","data",res);
		}catch (Exception e){
			error(e);
			return error(-1, e.getMessage());
		}
	}
	
}

+ 53 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -692,7 +692,9 @@ public class DoctorMessageController extends BaseController {
                              @ApiParam(name = "patient",value = "居民code",required = true)
                              @RequestParam(value = "patient",required = true)String patient,
                              @ApiParam(name = "time",value = "时间",required = false)
                              @RequestParam(value = "time",required = false)Integer time) {
                              @RequestParam(value = "time",required = false)Integer time,
                              @ApiParam(name = "jsonObject",value = "参数",required = false)
                              @RequestParam(value = "jsonObject",required = false) String jsonObject){
        try {
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(message);
            Message message1 = new Message();
@ -700,7 +702,8 @@ public class DoctorMessageController extends BaseController {
            message1.setType(object.getInteger("type"));
            message1.setReceiver(object.getString("receiver"));
            message1.setRelationCode(object.getString("relationCode"));
            return write(200, "获取消息成功!","data",specialistEvaluateSevice.sendMessage(message1,hospital,patient,time));
            com.alibaba.fastjson.JSONObject jsonObject1 = com.alibaba.fastjson.JSONObject.parseObject(jsonObject);
            return write(200, "获取消息成功!","data",specialistEvaluateSevice.sendMessage(message1,hospital,patient,time,jsonObject1));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
@ -759,5 +762,53 @@ public class DoctorMessageController extends BaseController {
    }
    /**
     * 获取协同服务消息列表
     *
     * @param message
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "getSynergyMessages",method = RequestMethod.GET)
    @ApiOperation("协同服务消息列表")
    @ResponseBody
    public String getSynergyMessage(@ApiParam(name = "message",value = "消息对象")@RequestParam(value = "message")String message,
                                       @ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page,
                                       @ApiParam(name="pageSize",value="",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize){
        if (StringUtils.isBlank(pageSize)) {
            pageSize = "10";
        }
        if (page.equals("0")) {
            page = "1";
        }
        Message message1 = new Message();
        com.alibaba.fastjson.JSONObject object = JSON.parseObject(message);
        message1.setReceiver(getUID());
        try {
            return write(200,"查询成功!","data",messageService.getSynergyMessages(message1,Integer.valueOf(page),Integer.valueOf(pageSize)));
        }catch (Exception e){
            error(e);
            return error( -1, "查询失败!");
        }
    }
    /**
     * 设置协同消息已读
     * @return
     */
    @RequestMapping(value = "setSynergyMessagesByRead",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("设置协同消息已读" )
    public String setSynergyMessagesByRead() {
        try {
            return write(200, "获取消息总数成功!", "data", messageService.setSynergyMessagesByRead(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 0 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java


Някои файлове не бяха показани, защото твърде много файлове са промени