Parcourir la source

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

huangwenjie il y a 7 ans
Parent
commit
53dbb671e1
92 fichiers modifiés avec 3453 ajouts et 326 suppressions
  1. 8 8
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyScreenResult.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  3. 89 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRecordLog.java
  4. 1 1
      edu-article/JkEdu/src/Article.sql.xml
  5. 1 1
      edu-article/JkEdu/src/com/yihu/jk/api/ArticleApi.java
  6. 9 0
      edu-article/JkEdu/src/com/yihu/jk/vo/ArticleStatistic.java
  7. 4 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/SpringSecurityConfig.java
  8. 12 10
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/datastatic/WeChatStaticController.java
  9. 6 5
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/healthbank/ActivityController.java
  10. 15 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/healthbank/TaskController.java
  11. 15 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/healthbank/TaskRuleController.java
  12. 53 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyAdviceController.java
  13. 64 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyTemplateAdviceController.java
  14. 10 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyTemplateController.java
  15. 58 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyTemplateResultController.java
  16. 10 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/wechat/WechatSignVO.java
  17. 23 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyAdviceDao.java
  18. 24 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateAdviceDao.java
  19. 28 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/survey/SurveyTemplateResultDao.java
  20. 2 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/healthbank/ActivityService.java
  21. 13 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/healthbank/TaskRuleService.java
  22. 13 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/healthbank/TaskService.java
  23. 57 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyAdviceService.java
  24. 48 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateAdviceService.java
  25. 62 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateResultService.java
  26. 7 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateService.java
  27. 31 11
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/wechat/WechatService.java
  28. 3 3
      patient-co-manage/wlyy-manage/src/main/resources/application.yml
  29. 4 1
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/healthbank/activity_list.jsp
  30. 14 5
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/healthbank/activity_list_js.jsp
  31. 7 4
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/healthbank/activity_modify_js.jsp
  32. 19 6
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/add_template.jsp
  33. 57 3
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/add_template_js.jsp
  34. 66 31
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/edit_template_js.jsp
  35. 121 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_advice.jsp
  36. 172 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_advice_js.jsp
  37. 8 5
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_list_js.jsp
  38. 90 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_result.jsp
  39. 134 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_result_js.jsp
  40. 13 8
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/static_wechat.jsp
  41. 25 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/static_wechat_js.jsp
  42. 2 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java
  43. 23 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java
  44. 9 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java
  45. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyTemplateResultDao.java
  46. 24 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  47. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientRecordLogDao.java
  48. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  49. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  50. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  51. 116 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  52. 8 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  53. 168 49
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  54. 667 31
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java
  55. 15 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  56. 123 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistScreenResultService.java
  57. 143 42
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
  58. 12 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/survey/ManagerQuestionnaireService.java
  59. 119 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  60. 0 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/IGuahaoService.java
  61. 10 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  62. 47 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java
  63. 33 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  64. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java
  65. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java
  66. 82 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  67. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  68. 48 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java
  69. 62 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistScreenResultController.java
  70. 62 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java
  71. 5 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java
  72. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  73. 3 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java
  74. 23 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java
  75. 3 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  76. 48 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/specialist/ThirdSpecialistController.java
  77. 41 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdQrcodeController.java
  78. 40 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java
  79. 60 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  80. 3 2
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  81. 2 0
      patient-co/patient-co-wlyy/src/main/resources/system.properties
  82. 5 0
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu.txt
  83. 5 0
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_haicang.txt
  84. 5 0
      patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt
  85. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/SpBanner.png
  86. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/banner01.png
  87. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/currency.png
  88. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/familycontract.png
  89. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/operatinginstructions.png
  90. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/patientPrenata.png
  91. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/visit.png
  92. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/xufangzhiyin_img.png

+ 8 - 8
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/survey/SurveyScreenResult.java

@ -41,7 +41,7 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    //是否高危预警(0不是  1是)
    private Integer isDanger;
    //是否预约(0未预约 1已预约)
    private Integer order;
    private Integer isOrder;
    //是否跟踪(0未跟踪 1已跟踪)
    private Integer following;
    //是否进行健康教育(0没有  1有)
@ -70,7 +70,7 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
    public SurveyScreenResult() {
    }
    public SurveyScreenResult(String code, String templateCode, String templateTitle, int disease, String doctor, String patientCode, String openId, String patientName, String screenResultCode, Integer screenResultScore, String screenResult, Integer isDanger, Integer order, Integer following, Integer isEducate, Integer over, String reservationCode, Date czrq, int isAgain, String parentCode, String originCode, String adviceCode, String otherAdvice, int source, Date updateTime) {
    public SurveyScreenResult(String code, String templateCode, String templateTitle, int disease, String doctor, String patientCode, String openId, String patientName, String screenResultCode, Integer screenResultScore, String screenResult, Integer isDanger, Integer isOrder, Integer following, Integer isEducate, Integer over, String reservationCode, Date czrq, int isAgain, String parentCode, String originCode, String adviceCode, String otherAdvice, int source, Date updateTime) {
        this.code = code;
        this.templateCode = templateCode;
        this.templateTitle = templateTitle;
@ -83,7 +83,7 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.screenResultScore = screenResultScore;
        this.screenResult = screenResult;
        this.isDanger = isDanger;
        this.order = order;
        this.isOrder = isOrder;
        this.following = following;
        this.isEducate = isEducate;
        this.over = over;
@ -206,13 +206,13 @@ public class SurveyScreenResult extends IdEntity implements Serializable{
        this.isDanger = isDanger;
    }
    @Column(name = "order")
    public int getOrder() {
        return order;
    @Column(name = "is_order")
    public Integer getIsOrder() {
        return isOrder;
    }
    public void setOrder(int order) {
        this.order = order;
    public void setIsOrder(Integer isOrder) {
        this.isOrder = isOrder;
    }
    @Column(name = "following")

+ 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.专科医生申请签约消息 18.专科医生同意签约发送给全科医生消息
	 *  16.专科医生申请签约消息,17、家庭医生转诊预约消息
	 *  101患者申请取消签约、102患者同意取消签约、103患者拒绝取消签约、104患者填写了血糖记录、105患者填写了血压记录、106患者填写了体重记录、
	 *  107患者填写了腰围记录、108患者填写了运动记录、109患者填写了用药记录、110患者填写了饮食记录、111患者提交了问卷随访、112请求添加好友消息、
	 *  113入群消息、114群解散消息、115踢出群消息、116新的网络咨询、117网络咨询追问、

+ 89 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRecordLog.java

@ -0,0 +1,89 @@
package com.yihu.wlyy.entity.patient;/**
 * Created by nature of king on 2018/7/12.
 */
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * @author wangzhinan
 * @create 2018-07-12 14:36
 * @desc 居民取消关注日志
 **/
@Entity
@Table(name = "wlyy_patient_record_log")
public class PatientRecordLog extends IdEntity implements Serializable{
    @Column(name = "patient")
    private String patient;
    @Column(name = "patient_name")
    private String patientName;
    @Column(name = "idCard")
    private String idCard;
    @Column(name = "ssc")
    private String ssc;
    @Column(name = "open_id")
    private String openId;
    @Column(name = "czrq")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date czrq;
    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 getIdCard() {
        return idCard;
    }
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public String getOpenId() {
        return openId;
    }
    public void setOpenId(String openId) {
        this.openId = openId;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 1 - 1
edu-article/JkEdu/src/Article.sql.xml

@ -32,7 +32,7 @@ User_ArticleStatistics n on aa.ArticleId=n.ArticleId where 1=1 @Condition
		<Sql name='getCollectionArticleList'>
			<![CDATA[
select aa.* ,n.BrowseNumber,n.PointNumber,n.CollectionNumber,IFNULL(n.CommentNumber,0) as CommentNumber, IFNULL(n.PushNumber,0) as PushNumber from (
select m.* from Org_Article m  INNER JOIN User_ArticleCollection n on  m.articleid=n.ArticleId and  1=1 and  m.ArticleState =1  @UserParam) as aa LEFT JOIN
select m.*,n.InsertTime as collectionInsertTime from Org_Article m  INNER JOIN User_ArticleCollection n on  m.articleid=n.ArticleId and  1=1 and  m.ArticleState =1  @UserParam) as aa LEFT JOIN
User_ArticleStatistics n on aa.ArticleId=n.ArticleId where 1=1 @Condition
			]]>
		</Sql>

+ 1 - 1
edu-article/JkEdu/src/com/yihu/jk/api/ArticleApi.java

@ -146,7 +146,7 @@ public class ArticleApi {
					jsonObj.put("articleSource", StringUtil.getJSONValue(vbo.getArticleSource()));
					jsonObj.put("articlelevel", StringUtil.getJSONValue(vbo.getArticlelevel()));
					jsonObj.put("articleCover", StringUtil.getJSONValue(vbo.getArticleCover()));
					jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getInsertTime()));
					jsonObj.put("insertTime", StringUtil.getJSONValue(vbo.getCollectionInsertTime()));
					jsonObj.put("updateTime", StringUtil.getJSONValue(vbo.getUpdateTime()));
					jsonObj.put("operatorName", StringUtil.getJSONValue(vbo.getOperatorName()));
					jsonObj.put("operatorId", StringUtil.getJSONValue(vbo.getOperatorId()));

+ 9 - 0
edu-article/JkEdu/src/com/yihu/jk/vo/ArticleStatistic.java

@ -48,6 +48,7 @@ public class ArticleStatistic {
	private String OperatorRoleLevel;//操作人角色级别
	private Integer UserScope;//使用范围(1、全市使用,2、全区使用,3、全社区使用)
	private Integer RoleType;//1、健管师,2、管理员
	private String collectionInsertTime;//收藏时间
	public String getDeptName() {
		return DeptName;
@ -376,4 +377,12 @@ public class ArticleStatistic {
	public void setPushNumber(Integer pushNumber) {
		PushNumber = pushNumber;
	}
	public String getCollectionInsertTime() {
		return collectionInsertTime;
	}
	public void setCollectionInsertTime(String collectionInsertTime) {
		this.collectionInsertTime = collectionInsertTime;
	}
}

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

@ -53,7 +53,10 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
                "/admin/wlyyUserRole/importData",
                "/admin/questionnaire/importData",
                "/WEB—INF/views/**",
                "/admin/specialDisease/**"
                "/admin/specialDisease/**",
                "/admin/surveyTemplateResult/**",
                "/admin/surveyAdvice/**",
                "/admin/surveyTemplateAdvice/**"
        );
    }

+ 12 - 10
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/datastatic/WeChatStaticController.java

@ -41,9 +41,10 @@ public class WeChatStaticController extends BaseController {
			@RequestParam(value = "town",required = false)String town,
			@RequestParam(value = "hospital",required = false)String hospital,
			@RequestParam(value = "attention",required = false)String attention,
			@RequestParam(value = "signSource",required = false)String signSource,
			HttpServletResponse response){
		try {
			List<WechatSignVO> datalist = wechatService.geSignWechatDataList(hospital,attention);
			List<WechatSignVO> datalist = wechatService.geSignWechatDataList(hospital,attention, signSource);
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename="+ new String( "signWechatDataList.xls"));
			OutputStream os = response.getOutputStream();
@ -120,7 +121,7 @@ public class WeChatStaticController extends BaseController {
			WritableSheet ws;
			ws = wwb.createSheet("sheet",1);
			
			String[] header = {"居民openid","居民姓名","手机号码","openid更新时间", "身份证号","全科医生", "健管师", "社区医院", "居委会","住址","街道","openid重复数"};
			String[] header = {"居民openid","居民姓名","手机号码","openid更新时间","医疗保险号", "身份证号","全科医生", "健管师", "社区医院", "居委会","住址","街道","openid重复数"};
			int k = 0;
			for (String h : header) {
				addCell(ws, 0, k, h);//表名,行,列,header
@ -133,14 +134,15 @@ public class WeChatStaticController extends BaseController {
				addCell(ws, i, 1, m.getPatientname(),"");
				addCell(ws, i, 2, m.getMobile(),"");
				addCell(ws, i, 3, m.getOpenid_time(),"");
				addCell(ws, i, 4, m.getIdcard(),"");
				addCell(ws, i, 5, m.getDoctor_name(),"");
				addCell(ws, i, 6, m.getDoctor_health_name(),"");
				addCell(ws, i, 7, m.getHospital_name(),"");
				addCell(ws, i, 8, m.getSick_village_name(),"");
				addCell(ws, i, 9, m.getAddress(),"");
				addCell(ws, i, 10, m.getStreet_name(),"");
				addCell(ws, i, 11, m.getTcount(),"");
				addCell(ws, i, 4, m.getMedicare_number(), "");
				addCell(ws, i, 5, m.getIdcard(),"");
				addCell(ws, i, 6, m.getDoctor_name(),"");
				addCell(ws, i, 7, m.getDoctor_health_name(),"");
				addCell(ws, i, 8, m.getHospital_name(),"");
				addCell(ws, i, 9, m.getSick_village_name(),"");
				addCell(ws, i, 10, m.getAddress(),"");
				addCell(ws, i, 11, m.getStreet_name(),"");
				addCell(ws, i, 12, m.getTcount(),"");
				i++;
			}
			wwb.write();

+ 6 - 5
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/healthbank/ActivityController.java

@ -5,7 +5,8 @@ import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.manager.healthbank.ActivityService;
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -61,7 +62,6 @@ public class ActivityController extends BaseController {
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            return write(200,"操作成功","detailModelList",activityService.searchList(activity, page, pageSize).get("detailModelList"));
//            return write(200,"操作成功");
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
@ -133,10 +133,11 @@ public class ActivityController extends BaseController {
    @RequestMapping(value = "delete")
    @ResponseBody
    public String delete(String id) {
    public String delete(@RequestParam(value = "id") String id) {
        try {
            String jsonData = "{\"id\":\""+ id + "\"}";
            activityService.delete(jsonData);
            String[] ids = {id};
            String s = JSONArray.fromObject(ids).toString();
            activityService.delete(s);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);

+ 15 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/healthbank/TaskController.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.controller.manager.healthbank;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.manager.healthbank.TaskService;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -87,4 +88,18 @@ public class TaskController extends BaseController {
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String delete(@RequestParam(value = "id") String id) {
        try {
            String[] ids = {id};
            String s = JSONArray.fromObject(ids).toString();
            taskService.delete(s);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 15 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/healthbank/TaskRuleController.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.controller.manager.healthbank;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.manager.healthbank.TaskRuleService;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -87,4 +88,18 @@ public class TaskRuleController extends BaseController {
            return error(-1,"操作失败!");
        }
    }
    @RequestMapping(value = "delete")
    @ResponseBody
    public String delete(@RequestParam(value = "id") String id) {
        try {
            String[] ids = {id};
            String s = JSONArray.fromObject(ids).toString();
            taskRuleService.delete(s);
            return write(200, "操作成功" );
        }catch (Exception ex){
            error(ex);
            return error(-1,"操作失败!");
        }
    }
}

+ 53 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyAdviceController.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.controller.manager.survey;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.survey.SurveyAdvice;
import com.yihu.wlyy.service.manager.survey.SurveyAdviceService;
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;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
@Controller
@RequestMapping(value="admin/surveyAdvice/")
public class SurveyAdviceController extends BaseController {
    @Autowired
    private SurveyAdviceService surveyAdviceService;
    @RequestMapping(value = "findByDiseaseType", method = RequestMethod.POST)
    @ResponseBody
    public String findById(
            @ApiParam(name = "diseaseType",value = "疾病类型")
            @RequestParam(value = "diseaseType",required = true) Integer diseaseType,
            @ApiParam(name = "templateCode",value = "模板id")
            @RequestParam(value = "templateCode",required = true) String templateCode){
        try {
            List<SurveyAdvice> results = surveyAdviceService.findAdvice(diseaseType, templateCode);
            return write(200, "操作成功","data",results);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "saveOrUpdate", method = RequestMethod.POST)
    @ResponseBody
    public String saveResult(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true) String jsonData){
        try {
            SurveyAdvice advice = surveyAdviceService.saveOrUpdate(jsonData);
            return write(200,"保存成功","data",advice);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
}

+ 64 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyTemplateAdviceController.java

@ -0,0 +1,64 @@
package com.yihu.wlyy.controller.manager.survey;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.survey.SurveyAdvice;
import com.yihu.wlyy.service.manager.survey.SurveyAdviceService;
import com.yihu.wlyy.service.manager.survey.SurveyTemplateAdviceService;
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;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
@Controller
@RequestMapping(value="admin/surveyTemplateAdvice/")
public class SurveyTemplateAdviceController extends BaseController {
    @Autowired
    private SurveyTemplateAdviceService templateAdviceService;
    @Autowired
    private SurveyAdviceService surveyAdviceService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    public String initAdvice(Integer diseaseType, String templateCode,String mode){
        request.setAttribute("templateCode",templateCode);
        request.setAttribute("diseaseType",diseaseType);
        request.setAttribute("mode",mode);
        return "questionnaire/template/template_advice";
    }
    @RequestMapping(value = "saveOrUpdate", method = RequestMethod.POST)
    @ResponseBody
    public String saveResult(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                             @RequestParam(value = "jsonData", required = true) String jsonData,
                             @ApiParam(name = "templateCode", value = "新增json",defaultValue = "")
                             @RequestParam(value = "templateCode", required = true) String templateCode){
        try {
            templateAdviceService.saveOrUpdate(jsonData, templateCode);
            return write(200,"保存成功");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
    @RequestMapping(value = "adviceList", method = RequestMethod.POST)
    @ResponseBody
    public String adviceList(@ApiParam(name = "templateCode", value = "新增json",defaultValue = "")
                             @RequestParam(value = "templateCode", required = true) String templateCode){
        try {
            List<SurveyAdvice> surveyAdviceList = surveyAdviceService.findAdviceByTemplateCode(templateCode);
            return write(200,"保存成功","data",surveyAdviceList);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
}

+ 10 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyTemplateController.java

@ -41,6 +41,14 @@ public class SurveyTemplateController extends BaseController{
        return "questionnaire/template/import_question";
    }
    //跳转到问卷模板筛查结果列表---
    @RequestMapping(value = "initResult", method = RequestMethod.GET)
    public String initResult(String templateCode, Integer diseaseType, String mode){
        request.setAttribute("templateCode",templateCode);
        request.setAttribute("diseaseType",diseaseType);
        request.setAttribute("mode",mode);
        return "questionnaire/template/template_result";
    }
    @RequestMapping(value = "list", method = RequestMethod.GET)
    @ResponseBody
@ -129,8 +137,8 @@ public class SurveyTemplateController extends BaseController{
                               HttpServletRequest request){
        User loginUser = (User) request.getSession().getAttribute("userInfo");
        try {
            surveyTemplateService.saveOrUpdate(jsonData,loginUser.getCode());
            return write(200,"保存成功");
            SurveyTemplate surveyTemplate = surveyTemplateService.saveOrUpdate(jsonData,loginUser.getCode());
            return write(200,"保存成功","data",surveyTemplate);
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");

+ 58 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/SurveyTemplateResultController.java

@ -0,0 +1,58 @@
package com.yihu.wlyy.controller.manager.survey;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.survey.SurveyTemplateResult;
import com.yihu.wlyy.service.manager.survey.SurveyTemplateResultService;
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;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
@Controller
@RequestMapping(value="admin/surveyTemplateResult/")
public class SurveyTemplateResultController extends BaseController {
    @Autowired
    private SurveyTemplateResultService resultService;
    @RequestMapping(value = "findByTemplateCode", method = RequestMethod.POST)
    @ResponseBody
    public String findById(
            @ApiParam(name = "templateCode",value = "模板id")
            @RequestParam(value = "templateCode",required = true) String templateCode){
        try {
            List<SurveyTemplateResult> results = resultService.findByTemplateCode(templateCode);
            return write(200, "操作成功","data",results);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    @RequestMapping(value = "save", method = RequestMethod.POST)
    @ResponseBody
    public String saveResult(@ApiParam(name = "jsonData", value = "新增json",defaultValue = "")
                               @RequestParam(value = "jsonData", required = true) String jsonData,
                             @ApiParam(name = "templateCode",value = "模板id")
                             @RequestParam(value = "templateCode",required = true) String templateCode,
                               HttpServletRequest request){
        User loginUser = (User) request.getSession().getAttribute("userInfo");
        try {
            resultService.saveOrUpdate(jsonData,templateCode,loginUser.getCode());
            return write(200,"保存成功");
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"保存失败");
        }
    }
}

+ 10 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/wechat/WechatSignVO.java

@ -11,6 +11,7 @@ public class WechatSignVO {
	private String patientname;
	private String mobile;
	private String openid_time;
	private String medicare_number;
	private String idcard;
	private String doctor_name;
	private String doctor_health_name;
@ -59,7 +60,15 @@ public class WechatSignVO {
	public void setOpenid_time(String openid_time) {
		this.openid_time = openid_time;
	}
	
	public String getMedicare_number() {
		return medicare_number;
	}
	public void setMedicare_number(String medicare_number) {
		this.medicare_number = medicare_number;
	}
	public String getIdcard() {
		return idcard;
	}

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

@ -0,0 +1,23 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyAdvice;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
public interface SurveyAdviceDao extends PagingAndSortingRepository<SurveyAdvice,Long>,JpaSpecificationExecutor<SurveyAdvice> {
    @Query(value = "SELECT a.* from wlyy_survey_advice a LEFT JOIN (SELECT * from wlyy_survey_template_advice where template_code=?2) ta on a.code = ta.advice_code where a.disease_type=?1 and ta.advice_code is null",nativeQuery = true)
    List<SurveyAdvice> findAdvice(Integer diseaseType, String templateCode);
    @Query("select s from SurveyAdvice s where s.code = ?1")
    SurveyAdvice findByCode(String adviceCode);
    @Query(value = "SELECT a.* from wlyy_survey_template_advice ta LEFT JOIN wlyy_survey_advice a on ta.advice_code = a.code where ta.template_code = ?1",nativeQuery = true)
    List<SurveyAdvice> findAdviceByTemplateCode(String templateCode);
}

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

@ -0,0 +1,24 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyAdvice;
import com.yihu.wlyy.entity.survey.SurveyTemplateAdvice;
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 javax.transaction.Transactional;
import java.util.List;
public interface SurveyTemplateAdviceDao extends PagingAndSortingRepository<SurveyTemplateAdvice,Long>,JpaSpecificationExecutor<SurveyTemplateAdvice> {
    List<SurveyTemplateAdvice> findByTemplateCode(String templateCode);
    @Query(value = "SELECT a.* from wlyy_survey_template_advice ta LEFT JOIN wlyy_survey_advice a on ta.advice_code = a.code where ta.template_code = ?1",nativeQuery = true)
    List<SurveyAdvice> findAdviceByTemplateCode(String templateCode);
    @Query("delete from SurveyTemplateAdvice s where s.templateCode=?1")
    @Modifying
    @Transactional
    void deleteByTemplateCode(String templateCode);
}

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

@ -0,0 +1,28 @@
package com.yihu.wlyy.repository.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateResult;
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 javax.transaction.Transactional;
import java.util.List;
/**
 * Created by humingfen on 2018/7/5.
 */
public interface  SurveyTemplateResultDao extends PagingAndSortingRepository<SurveyTemplateResult,Long>,JpaSpecificationExecutor<SurveyTemplateResult> {
    @Query("select s from SurveyTemplateResult s where s.templateCode = ?1 and s.del = 1")
    List<SurveyTemplateResult> findByTemplateCode(String templateCode);
    @Query("update SurveyTemplateResult s set s.del = 0 where s.templateCode=?1 and s.del = 1")
    @Modifying
    @Transactional
    void deleteByTemplateCode(String templateCode);
    @Query("update SurveyTemplateResult s set s.del = 1 where s.id = ?1 and s.del = 0")
    @Modifying
    @Transactional
    void updateDel(long id);
}

+ 2 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/healthbank/ActivityService.java

@ -68,11 +68,11 @@ public class ActivityService {
        return JSONObject.parseObject(response);
    }
    public JSONObject delete(String jsonData) {
    public JSONObject delete(String ids) {
        String url = baseUrl + "batchActivity";
        String response = "";
        Map<String,String> params = new HashMap<>();
        params.put("ids",jsonData);
        params.put("ids",ids);
        try {
            response = httpClientUtil.httpPost(url,params);
        } catch (Exception e) {

+ 13 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/healthbank/TaskRuleService.java

@ -67,4 +67,17 @@ public class TaskRuleService {
        }
        return JSONObject.parseObject(response);
    }
    public JSONObject delete(String ids) {
        String url = baseUrl + "batchTaskRule";
        String response = "";
        Map<String,String> params = new HashMap<>();
        params.put("ids",ids);
        try {
            response = httpClientUtil.httpPost(url,params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return JSONObject.parseObject(response);
    }
}

+ 13 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/healthbank/TaskService.java

@ -67,4 +67,17 @@ public class TaskService {
        }
        return JSONObject.parseObject(response);
    }
    public JSONObject delete(String ids) {
        String url = baseUrl + "batchTask";
        String response = "";
        Map<String,String> params = new HashMap<>();
        params.put("ids",ids);
        try {
            response = httpClientUtil.httpPost(url,params);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return JSONObject.parseObject(response);
    }
}

+ 57 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyAdviceService.java

@ -0,0 +1,57 @@
package com.yihu.wlyy.service.manager.survey;
import com.yihu.wlyy.entity.survey.SurveyAdvice;
import com.yihu.wlyy.entity.survey.SurveyTemplateAdvice;
import com.yihu.wlyy.repository.survey.SurveyAdviceDao;
import com.yihu.wlyy.util.ClazzReflect;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 问卷调查指导建议表
 * Created by hmf on 2018/7/5.
 */
@Service
public class SurveyAdviceService extends BaseJpaService<SurveyAdvice,Long> {
    @Autowired
    private SurveyAdviceDao surveyAdviceDao;
    public SurveyAdvice saveOrUpdate(String jsonData) {
        JSONObject jsonObject = new JSONObject(jsonData);
        ClazzReflect clazzReflect = new ClazzReflect();
        SurveyAdvice surveyAdvice = new SurveyAdvice();
        surveyAdvice.setCode(getCode());
        surveyAdvice.setCzrq(new Date());
        clazzReflect.formatToClazz(surveyAdvice,jsonObject);
        surveyAdviceDao.save(surveyAdvice);
        return surveyAdvice;
    }
    public SurveyAdvice findById(Long id){
        return  surveyAdviceDao.findOne(id);
    }
    public List<SurveyAdvice> findAdvice(Integer diseaseType, String templateCode) {
        return surveyAdviceDao.findAdvice(diseaseType, templateCode);
    }
    public List<SurveyAdvice> findByCode(List<SurveyTemplateAdvice> templateAdviceList) {
        List<SurveyAdvice> surveyAdviceList = new ArrayList<>();
        for(SurveyTemplateAdvice templateAdvice : templateAdviceList){
            SurveyAdvice surveyAdvice = new SurveyAdvice();
            surveyAdvice = surveyAdviceDao.findByCode(templateAdvice.getAdviceCode());
            surveyAdviceList.add(surveyAdvice);
        }
        return surveyAdviceList;
    }
    public List<SurveyAdvice> findAdviceByTemplateCode(String templateCode) {
        return surveyAdviceDao.findAdviceByTemplateCode(templateCode);
    }
}

+ 48 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateAdviceService.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.service.manager.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateAdvice;
import com.yihu.wlyy.repository.survey.SurveyTemplateAdviceDao;
import com.yihu.wlyy.util.ClazzReflect;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 问卷调查建议关联表
 * Created by hmf on 2018/7/5.
 */
@Service
public class SurveyTemplateAdviceService extends BaseJpaService<SurveyTemplateAdvice,Long> {
    @Autowired
    private SurveyTemplateAdviceDao templateAdviceDao;
    public void saveOrUpdate(String jsonData, String templateCode) {
        JSONArray array = new JSONArray(jsonData);
        List<SurveyTemplateAdvice> templateAdviceList = new ArrayList<>();
        templateAdviceDao.deleteByTemplateCode(templateCode);
        for(Object object:array) {
            JSONObject jsonObject = (JSONObject)object;
            ClazzReflect clazzReflect = new ClazzReflect();
            SurveyTemplateAdvice templateAdvice = new SurveyTemplateAdvice();
            templateAdvice.setCzrq(new Date());
            clazzReflect.formatToClazz(templateAdvice,jsonObject);
            templateAdviceList.add(templateAdvice);
        }
        templateAdviceDao.save(templateAdviceList);
    }
    public SurveyTemplateAdvice findById(Long id){
        return  templateAdviceDao.findOne(id);
    }
    public List<SurveyTemplateAdvice> findByTemplateCode(String templateCode) {
        return templateAdviceDao.findByTemplateCode(templateCode);
    }
}

+ 62 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/SurveyTemplateResultService.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.service.manager.survey;
import com.yihu.wlyy.entity.survey.SurveyTemplateResult;
import com.yihu.wlyy.repository.survey.SurveyTemplateResultDao;
import com.yihu.wlyy.util.ClazzReflect;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 问卷调查模板评分筛查表
 * Created by hmf on 2018/7/5.
 */
@Service
public class SurveyTemplateResultService extends BaseJpaService<SurveyTemplateResult,Long> {
    @Autowired
    private SurveyTemplateResultDao resultDao;
    public void saveOrUpdate(String jsonData, String templateCode, String loginUserId) {
        JSONArray array = new JSONArray(jsonData);
        List<SurveyTemplateResult> resultList = new ArrayList<>();
        resultDao.deleteByTemplateCode(templateCode);
        for(Object object:array) {
            JSONObject jsonObject = (JSONObject)object;
            ClazzReflect clazzReflect = new ClazzReflect();
            SurveyTemplateResult result = new SurveyTemplateResult();
            if(!jsonObject.isNull("id")&&StringUtils.isNotBlank(jsonObject.getString("id"))){
                result = this.findById(jsonObject.getLong("id"));
                if(result.getDel() == 0){
                    result.setDel(1);
                }
            }else {
                result.setCode(getCode());
                result.setCreateUserName(loginUserId + "");
                result.setCreateTime(new Date());
                result.setDel(1);
            }
            result.setUpdateTime(new Date());
            if(jsonObject.getString("highScore").equals("null")){
                jsonObject.remove("highScore");
            }
            clazzReflect.formatToClazz(result,jsonObject);
            resultList.add(result);
        }
        resultDao.save(resultList);
    }
    public SurveyTemplateResult findById(Long id){
        return  resultDao.findOne(id);
    }
    public List<SurveyTemplateResult> findByTemplateCode(String templateCode) {
        return resultDao.findByTemplateCode(templateCode);
    }
}

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

@ -54,16 +54,17 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
    UserService userService;
    @Transactional
    public void saveOrUpdate(String jsonData,String loginUserId){
    public SurveyTemplate saveOrUpdate(String jsonData,String loginUserId){
        JSONArray array = new JSONArray(jsonData);
        List<SurveyTemplate> surveyTemplates = new ArrayList<>();
        List<SurveyTemplateQuestion> surveyTemplateQuestions = new ArrayList<>();
        List<SurveyTemplateOption> surveyTemplateOptions = new ArrayList<>();
        List<SurveyLabelInfo> surveyLabelInfos = new ArrayList<>();
        SurveyTemplate surveyTemplate = null;
        for(Object object:array){
            JSONObject jsonObject = (JSONObject)object;
            ClazzReflect clazzReflect = new ClazzReflect();
            SurveyTemplate surveyTemplate = new SurveyTemplate();
            surveyTemplate = new SurveyTemplate();
            if(!jsonObject.isNull("id")&&StringUtils.isNotBlank(jsonObject.getString("id"))){
                surveyTemplate = this.findById(jsonObject.getLong("id"));
            }else{
@ -73,6 +74,9 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
                surveyTemplate.setDel("1");
            }
            surveyTemplate.setUpdateTime(new Date());
            if(StringUtils.isBlank(jsonObject.getString("diseaseType"))){
                jsonObject.remove("diseaseType");
            }
            clazzReflect.formatToClazz(surveyTemplate,jsonObject);
            surveyTemplates.add(surveyTemplate);
@ -123,6 +127,7 @@ public class SurveyTemplateService extends BaseJpaService<SurveyTemplate,Long> {
        surveyTemplateQuestionService.save(surveyTemplateQuestions);
        surveyTemplateOptionService.save(surveyTemplateOptions);
        surveyLabelInfoService.save(surveyLabelInfos);
        return surveyTemplate;
    }
    public SurveyTemplate findById(Long id){

+ 31 - 11
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/wechat/WechatService.java

@ -10,6 +10,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -30,8 +31,13 @@ public class WechatService extends BaseService {
	 * @param attention
	 * @return
	 */
	public List<WechatSignVO> geSignWechatDataList(String hospital,String attention) {
		
	public List<WechatSignVO> geSignWechatDataList(String hospital,String attention, String signSource) {
		Calendar a = Calendar.getInstance();
		int year = a.get(Calendar.YEAR)-1;
		int month = a.get(Calendar.MONTH)+1;
		if(month >= 7){
			year = a.get(Calendar.YEAR);
		}
		List<WechatSignVO> list = new ArrayList<>();
		String sql  = "";
		if("1".equals(attention)){
@ -41,6 +47,7 @@ public class WechatService extends BaseService {
					"t.NAME as patientname," +
					"a.mobile," +
					"t.openid_time," +
					"t.medicare_number,"+
					"CONCAT(LEFT (a.idcard,6),'**********',RIGHT (a.idcard,2)) idcard," +
					"a.doctor_name," +
					"a.doctor_health_name," +
@ -48,15 +55,16 @@ public class WechatService extends BaseService {
					"t.address," +
					"a.hospital_name,"+
					"t.street_name FROM (" +
					"SELECT b.patient,b.mobile,b.idcard,b.doctor_name,b.doctor_health_name,b.hospital_name FROM wlyy_sign_family b WHERE b.hospital='"+hospital+"' AND b.sign_year=2017 AND b.STATUS=1 AND b.expenses_status=1) a,wlyy_patient t WHERE t.CODE=a.patient) m," +
					"SELECT b.patient,b.mobile,b.idcard,b.doctor_name,b.doctor_health_name,b.hospital_name FROM wlyy_sign_family b WHERE b.hospital='"+hospital+"' AND b.sign_year='"+year+"' AND b.STATUS=1 AND b.expenses_status=1) a,wlyy_patient t WHERE t.CODE=a.patient) m," +
					"(SELECT t.openid,count(t.openid) tcount FROM wlyy_patient t WHERE t.`code` IN (" +
					"SELECT patient FROM wlyy_sign_family s WHERE s.hospital='"+hospital+"' AND s.sign_year=2017 AND s.expenses_status=1 AND s.STATUS=1) GROUP BY t.openid) n WHERE m.openid=n.openid";
					"SELECT patient FROM wlyy_sign_family s WHERE s.hospital='"+hospital+"' AND s.sign_year='"+year+"' AND s.expenses_status=1 AND s.STATUS=1 AND s.sign_source = '"+signSource+"') GROUP BY t.openid) n WHERE m.openid=n.openid";
		}else if("0".equals(attention)){
			sql = "SELECT m.*FROM (" +
			sql = "SELECT m.* FROM (" +
					"SELECT a.mobile," +
					"a.code as patientcode ," +
					"a.NAME as patientname ," +
					"a.openid_time," +
					"a.medicare_number," +
					"CONCAT(LEFT (a.idcard,6),'**********',RIGHT (a.idcard,2)) idcard," +
					"b.doctor_name," +
					"b.doctor_health_name," +
@ -64,8 +72,8 @@ public class WechatService extends BaseService {
					"a.address," +
					"a.sick_village_name," +
					"a.street_name FROM (" +
					"SELECT t.CODE,t.NAME,t.address,t.sick_village_name,t.street_name,idcard,mobile,openid_time FROM wlyy_patient t WHERE t.`code` IN (" +
					"SELECT patient FROM wlyy_sign_family s WHERE s.hospital='"+hospital+"' AND s.sign_year=2017 AND s.expenses_status=1 AND s.STATUS=1 AND s.expenses_time IS NOT NULL) AND t.openid IS NULL) a,wlyy_sign_family b WHERE b.hospital='"+hospital+"' AND b.sign_year=2017 AND b.STATUS=1 AND b.expenses_status=1 AND a.CODE=b.patient AND b.expenses_time IS NOT NULL) m";
					"SELECT t.CODE,t.NAME,t.address,t.sick_village_name,t.street_name,t.medicare_number,idcard,mobile,openid_time FROM wlyy_patient t WHERE t.`code` IN (" +
					"SELECT patient FROM wlyy_sign_family s WHERE s.hospital='"+hospital+"' AND s.sign_year='"+year+"' AND s.expenses_status=1 AND s.STATUS=1 AND s.expenses_time IS NOT NULL) AND t.openid IS NULL) a,wlyy_sign_family b WHERE b.hospital='"+hospital+"' AND b.sign_year='"+year+"' AND b.STATUS=1 AND b.expenses_status=1 AND a.CODE=b.patient AND b.expenses_time IS NOT NULL AND b.sign_source ='"+signSource+"') m";
		}
		
@ -80,6 +88,12 @@ public class WechatService extends BaseService {
	 */
	public List<WechatTotalVO> hosipitaTotalData() {
		List<WechatTotalVO> list = new ArrayList<>();
		Calendar a = Calendar.getInstance();
		int year = a.get(Calendar.YEAR)-1;
		int month = a.get(Calendar.MONTH)+1;
		if(month >= 7){
			year = a.get(Calendar.YEAR);
		}
		String sql  = "SELECT " +
				"a1.hospital_name as name," +
				"(a1.count/a2.count) as attRate," +
@ -89,10 +103,10 @@ public class WechatService extends BaseService {
				"FROM wlyy_patient p,wlyy_sign_family sf WHERE p.idcard=sf.idcard AND sf.type=2 " +
				"AND sf.STATUS> 0 AND LENGTH(sf.hospital)=10 " +
				"AND sf.admin_team_code IS NOT NULL AND p.openid IS NOT NULL " +
				"AND p.openid_time<= '"+ DateUtil.dateToStrShort(new Date())+"' AND sf.sign_year='2017' GROUP BY sf.hospital ORDER BY count desc) a1," +
				"AND p.openid_time<= '"+ DateUtil.dateToStrShort(new Date())+"' AND sf.sign_year='"+year+"' GROUP BY sf.hospital ORDER BY count desc) a1," +
				"(SELECT a.hospital hospital,count(a.id) count,a.hospital_name hospital_name " +
				"FROM wlyy_sign_family a WHERE STATUS IN (1,2) AND a.type=2 AND expenses_status=1 " +
				"AND a.expenses_time<= '"+ DateUtil.dateToStrShort(new Date())+"' AND a.sign_year='2017' GROUP BY a.hospital ORDER BY count desc) a2 WHERE a1.hospital=a2.hospital";
				"AND a.expenses_time<= '"+ DateUtil.dateToStrShort(new Date())+"' AND a.sign_year='"+year+"' GROUP BY a.hospital ORDER BY count desc) a2 WHERE a1.hospital=a2.hospital";
	
		list =  jdbcTemplate.query(sql,new BeanPropertyRowMapper(WechatTotalVO.class));
		return list ;
@ -105,6 +119,12 @@ public class WechatService extends BaseService {
	 */
	public List<WechatTotalVO> townTotalData() {
		List<WechatTotalVO> list = new ArrayList<>();
		Calendar a = Calendar.getInstance();
		int year = a.get(Calendar.YEAR)-1;
		int month = a.get(Calendar.MONTH)+1;
		if(month >= 7){
			year = a.get(Calendar.YEAR);
		}
		String sql  = "SELECT " +
				"a1.town_name as name," +
				"(a1.count/a2.count) as attRate," +
@ -115,10 +135,10 @@ public class WechatService extends BaseService {
				"FROM wlyy_patient p,wlyy_sign_family sf,dm_hospital h WHERE p.idcard=sf.idcard " +
				"AND sf.type=2 AND sf.STATUS> 0 AND LENGTH(sf.hospital)=10 AND sf.hospital=h.CODE " +
				"AND sf.admin_team_code IS NOT NULL AND p.openid IS NOT NULL " +
				"AND p.openid_time< '"+ DateUtil.dateToStrShort(new Date())+"' AND sf.sign_year='2017' GROUP BY h.town ORDER BY count desc) a1,(" +
				"AND p.openid_time< '"+ DateUtil.dateToStrShort(new Date())+"' AND sf.sign_year='"+year+"' GROUP BY h.town ORDER BY count desc) a1,(" +
				"SELECT count(a.id) count,h.town_name town_name,h.town town FROM wlyy_sign_family a,dm_hospital h" +
				" WHERE STATUS IN (1,2) AND a.type=2 AND expenses_status=1 AND a.hospital=h.CODE " +
				"AND a.expenses_time< '"+ DateUtil.dateToStrShort(new Date())+"' AND a.sign_year='2017' GROUP BY h.town) a2 WHERE a1.town=a2.town";
				"AND a.expenses_time< '"+ DateUtil.dateToStrShort(new Date())+"' AND a.sign_year='"+year+"' GROUP BY h.town) a2 WHERE a1.town=a2.town";
		
		list =  jdbcTemplate.query(sql,new BeanPropertyRowMapper(WechatTotalVO.class));
		return list ;

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

@ -102,7 +102,7 @@ reservation:
  zyurl: http://59.61.92.90:8072/wlyy_service
#健康活动url
healthbank:
  url: http://localhost:10051/svr-health-bank/
  url: http://172.19.103.33:8660/svr-wlyy-health-bank/svr-health-bank/
wechat:
  appId: wxd03f859efdf0873d
@ -210,7 +210,7 @@ reservation:
  zyurl: http://59.61.92.90:8072/wlyy_service
#健康活动url
healthbank:
  url: http://localhost:10051/svr-health-bank/
  url: http://172.19.103.33:8660/svr-wlyy-health-bank/svr-health-bank/
wechat:
  appId: wx1f129f7b51701428
  appSecret: 988f005d8309ed1795939e0f042431fb
@ -317,7 +317,7 @@ reservation:
  zyurl: http://59.61.92.90:8072/wlyy_service
#健康活动url
healthbank:
  url: http://localhost:10051/svr-health-bank/
  url: http://172.19.103.33:8660/svr-wlyy-health-bank/svr-health-bank/
wechat:
  appId: wxad04e9c4c5255acf
  appSecret: ae77c48ccf1af5d07069f5153d1ac8d3

+ 4 - 1
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/healthbank/activity_list.jsp

@ -18,7 +18,7 @@
    <div class="m-activity-area f-h50 f-dn f-pr m-form-inline" data-role-form style='display: block;'>
        <div class="m-form-group f-mt10">
            <div class="m-form-control f-ml15">
                <input type="text" id="inp_title" placeholder="请输入活动名称" class="f-ml10" data-attr-scan="title"/>
                <input type="text" id="inp_title" placeholder="请输入活动标题" class="f-ml10" data-attr-scan="title"/>
            </div>
            <div class="m-form-control f-ml15">
                <input type="text" id="inp_location" placeholder="请输入活动地点" class="f-ml10" data-attr-scan="location"/>
@ -26,6 +26,9 @@
            <div class="m-form-control f-ml15">
                <input type="text" id="inp_type" placeholder="请输入活动类型" class="f-ml10" data-attr-scan="type"/>
            </div>
            <div class="m-form-control f-ml15">
                <input type="text" id="inp_status" placeholder="请输入状态" class="f-ml10" data-attr-scan="status"/>
            </div>
            <div class="m-form-control f-ml15">
                <input type="text" id="inp_start_time" placeholder="请输入活动开始时间" class="f-ml10" data-attr-scan="startTime"/>
            </div>

+ 14 - 5
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/healthbank/activity_list_js.jsp

@ -33,6 +33,7 @@
                $title: $("#inp_title"),//活动名称
                $type: $("#inp_type"),
                $location: $("#inp_location"),
                $status: $("#inp_status"),//状态
                $startTime: $("#inp_start_time"),
                $endTime: $("#inp_end_time"),
                init: function () {
@ -42,6 +43,14 @@
                    this.$title.ligerTextBox({width: 200});
                    this.$type.ligerTextBox({width: 200});
                    this.$location.ligerTextBox({width: 200});
                    this.statusBox = this.$status.ligerComboBox({
                        width: 200,
                        data: [
                            {text: '报名中', id: '1'},
                            {text: '进行时', id: '0'},
                            {text: '已结束', id: '-1'},
                        ]
                    });
                    this.$startTime.ligerDateEditor({
                        format: "yyyy-MM-dd",
                        showTime: false,
@ -93,13 +102,13 @@
                                display: '活动状态', name: 'status', width: '10%', align: "left",
                                render: function (row) {
                                    if (row.status == 1) {
                                        return "有效"
                                        return "报名中"
                                    }
                                    if (row.status == 0) {
                                        return "无效"
                                        return "进行时"
                                    }
                                    if (row.status == -1) {
                                        return "过期"
                                        return "已结束"
                                    }
                                }
                            },
@ -112,9 +121,9 @@
                                    <sec:authorize url="/admin/activity/update">
                                    html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "activity:info:edit", row.id) + '">编辑</a>';
                                    </sec:authorize>
                                    <sec:authorize url="/admin/activity/delete">
                                    <%--<sec:authorize url="/admin/activity/delete">
                                    html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "activity:info:del", row.id) + '">删除</a>';
                                    </sec:authorize>
                                    </sec:authorize>--%>
                                    return html;
                                }
                            }

+ 7 - 4
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/healthbank/activity_modify_js.jsp

@ -47,9 +47,9 @@
                    $("#inp_status").ligerComboBox({
                        width: 240,
                        data: [
                            {text: '有效', id: '1'},
                            {text: '无效', id: '0'},
                            {text: '过期', id: '-1'},
                            {text: '报名中', id: '1'},
                            {text: '进行时', id: '0'},
                            {text: '已结束', id: '-1'},
                        ]
                    })//状态
                    $("#inp_isFlag").ligerComboBox({
@ -130,6 +130,7 @@
                                $("#inp_isFlag").ligerComboBox("selectValue",data.isFlag);
                                $("#inp_areaType").ligerComboBox("selectValue",data.areaType);
                                if(data.img != null) {
                                    _this.$imgUrl = data.img;
                                    var length = data.img.split(',').length;
                                    $('#img_upload').after('<li id="url">' + length + '张图片</li>');
                                }
@ -166,7 +167,9 @@
                    var self = this;
                    $("#btn_save").click(function () {
                        var values = self.$form.Fields.getValues();
                        values.img = self.$imgUrl;
                        if(values.img != '') {
                            values.img = self.$imgUrl;
                        }
                        values.status = $("#inp_status").ligerComboBox("getValue");
                        values.isFlag = $("#inp_isFlag").ligerComboBox("getValue");
                        values.areaType = $("#inp_areaType").ligerComboBox("getValue");

+ 19 - 6
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/add_template.jsp

@ -34,13 +34,15 @@
		.f-pr{position: relative;}
		.f-mt20{margin-top: 20px;}
		.f-mt160{margin-top: 160px;}
		.div-bottom{height: 50%;position: relative;top: 55%;}
		.div-prev,.div-next{height: 50%;border-bottom: 1px solid #dcdcdc;text-align: center;width: 100%;position: absolute;top: 0;}
		.div-bottom{border-top: 1px solid #dcdcdc;padding-top: 20px;}
		.div-prev,.div-next{text-align: center;width: 100%;padding-bottom: 20px;min-height: 50%;}
		.div-prev{padding-top: 160px}
		.div-next{padding-top: 20px}
		.div-prev .position-relative{display: inline-block;position: relative;height: 100%;margin-left: -176px;top: 2px;}
		.div-combox{position: absolute; left: 77px;top: -13px;}
		.f-tac{text-align: center}
		.f-dn{display: none;}
		#div-form{width: 500px;position: absolute;top: 50%;margin-top: -102px;left: 50%;margin-left: -250px;}
		#div-form{width: 500px;position: relative;left: 50%;margin-left: -250px}
		.div-next .position-relative{display: inline-block;position: relative;top: -3px;}
		.div-textarea{height: 148px; border: 1px solid #dcdcdc;padding:5px;}
		.div-label{top: 7px;display: inline-block;}
@ -51,7 +53,7 @@
	<input type="hidden" id="inp_mode" value='${mode}'/>
	<input type="hidden" id="inp_template_id" value='${templateId}'/>
	<div class="div-prev f-dn">
		<div class="f-pr f-mt160 div-type" data-type="1">
		<div class="f-pr div-type" data-type="1">
			<div class="div-radio-img active"></div>
			<div class="position-relative">
				<div>创建空白模板</div>
@ -71,7 +73,13 @@
	</div>
	<div class="div-next f-dn">
		<div id="div-form" data-role-form class="m-form-inline f-mt20">
		<div id="div-form" data-role-form class="m-form-inline">
			<div class="m-form-group">
				<label>发布机构</label>
				<div class="l-text-wrapper m-form-control essential">
					<input type="text" id="inp_organization" class="required ajax useTitle" required-title="发布机构不能为空">
				</div>
			</div>
			<div class="m-form-group">
				<label>问卷名称</label>
				<div class="l-text-wrapper m-form-control essential">
@ -90,9 +98,14 @@
				</div>
			</div>
			<div class="m-form-group" style="display:none" id="diseaseType">
				<label>筛查类型</label>
				<div class="l-text-wrapper m-form-control essential">
					<input type="text" id="inp_diseaseType" class="ajax useTitle" required-title="疾病类型不能为空">
				</div>
			</div>
		</div>
	</div>
	<div class="div-bottom f-tac">
		<input type="button" value="上一步" id="pre_btn" class="l-button u-btn u-btn-primary u-btn-large f-ib f-vam f-mr60 f-dn">
		<input type="button" value="下一步" id="next_btn" class="l-button u-btn u-btn-primary u-btn-large f-ib f-vam f-mr60 f-ml20">

+ 57 - 3
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/add_template_js.jsp

@ -10,6 +10,8 @@
			var Util = $.Util;
			var retrieve = null;
			var jValidation = $.jValidation;
			//判断是否为选中评分筛查按钮
			var flag = 0;
			/* *************************** 函数定义 ******************************* */
			function pageInit() {
@ -20,8 +22,25 @@
			retrieve = {
				$selWenJuan: $("#sel_wenjuan"),//选择问卷
                $diseaseType: $("#inp_diseaseType"),//疾病类型
				init: function () {
					var self = this;
                    $("#inp_organization").ligerTextBox({width: 240});
                    self.diseaseTypeBox = self.$diseaseType.ligerComboBox({
                        width: 240,
                        url: ctx + "/admin/specialDisease/list",
                        dataParmName: "data",
                        textField: "name",
                        valueField: "code",
                        isMultiSelect: false,
                        ajaxBeforeSend: function (xhr) {
                            if (ajaxHeaderName) {
                                xhr.setRequestHeader(ajaxHeaderName, ajaxHeaderValue);
                            }
                        },
                    });
                    this.loadLabel();
					if($("#inp_template_id").val()!=""){
						$(".div-next").show();
						self.loadTemplateContent();
@ -29,7 +48,6 @@
						self.selectBind();
						$(".div-prev").show();
					}
					this.loadLabel();
					this.bindEvents();
				},
				selectBind:function(){
@ -129,13 +147,43 @@
						$(this).addClass("active");
					}).on("click",".div-checkbox-img",function(){
						$(this).toggleClass("active");
						// 判断是否选中评分筛查,以及是否显示疾病类型
                        if($(this).next().find("div").html() == "评分筛查"){
                            if( flag == 0){
                                var allLabel = $(".div-label-content .div-label");
                                for(var i=0;i<allLabel.length;i++){
                                    $(allLabel[i]).find(".div-checkbox-img").removeClass("active");
                                }
                                $(this).addClass("active");
                                $("#diseaseType").show();
                                $("#inp_diseaseType").addClass("required");
                                flag = 1;
                            }else{
                                $("#diseaseType").hide();
                                $("#inp_diseaseType").removeClass("required");
                                flag = 0;
                            }
                        }else{
                            var allLabel = $(".div-label-content .div-label");
                            for(var i=0;i<allLabel.length;i++){
                                var labelId = $(allLabel[i]).attr("data-id");
                                for(var j=0;j<allLabel.length;j++){
                                    if(labelId == 5){
                                        $(allLabel[i]).find(".div-checkbox-img").removeClass("active");
                                        break;
                                    }
                                }
                            }
                            $("#diseaseType").hide();
                            $("#inp_diseaseType").removeClass("required");
                            flag = 0;
                        }
					}).on("click","#pre_btn",function(){//上一步事件
						$(this).hide();
						$("#next_btn").show();
						$(".div-prev").show();
						$(".div-next").hide();
					}).on("click","#next_btn",function(){//下一步事件
						debugger
						if($(".div-prev").is(":hidden")){//上一步内容显示
							if (!validator.validate()) {
								return;
@ -156,9 +204,10 @@
								}
							}
							labelsName = labelsName.substring(0,labelsName.length-1);
							var diseaseType = self.diseaseTypeBox.getValue();
							var type = $(".div-prev").find(".div-radio-img.active").closest(".div-type").attr("data-type");
							var templateId = (self.$selWenJuan.val()==null || type=="1")? $("#inp_template_id").val():self.$selWenJuan.val();
							var templateData = {templateId:templateId,title:$("#inp_wenjuan_name").val(),comment:$("#tea_wenjuan_instruction").val(),labels:JSON.stringify(labelArr),labelsName:labelsName};
							var templateData = {templateId:templateId,organization:$("#inp_organization").val(),title:$("#inp_wenjuan_name").val(),comment:$("#tea_wenjuan_instruction").val(),labels:JSON.stringify(labelArr),labelsName:labelsName,diseaseType:diseaseType};
							sessionStorage.setItem("templateData", JSON.stringify(templateData));
							location.href =  ctx + '/admin/surveyTemplate/editTemplate?id='+templateId+'&mode='+$("#inp_mode").val();
						}else{//上一步内容隐藏
@ -199,12 +248,17 @@
								var labels = data.labels;
								$("#inp_wenjuan_name").val(data.title);
								$("#tea_wenjuan_instruction").val(data.comment);
                                $("#inp_organization").val(data.organization);
								var allLabel = $(".div-label-content .div-label");
								for(var i=0;i<allLabel.length;i++){
									var labelId = $(allLabel[i]).attr("data-id");
									for(var j=0;j<labels.length;j++){
										if(labelId==labels[j].label.toString()){
											$(allLabel[i]).find(".div-checkbox-img").addClass("active");
											if(labelId == 5){
                                                $("#diseaseType").show();
                                                self.diseaseTypeBox.selectValue(data.diseaseType);
                                            }
											break;
										}
									}

+ 66 - 31
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/edit_template_js.jsp

@ -22,6 +22,8 @@
			var divLuojiSettingDialog = null;
			var questionType = "";
			var templateData = JSON.parse(sessionStorage.getItem("templateData"));//上一个页面(新增或编辑模板页传过来的信息:问卷名称、问卷说明、问卷标签)
            var labelLength = JSON.parse(templateData.labels).length-1;
            var label = JSON.parse(templateData.labels)[labelLength].label;
			/* *************************** 函数定义 ******************************* */
			function pageInit() {
				retrieve.init();
@ -251,17 +253,18 @@
						var item = '<li class="choice" data-input="0" data-input-required="0" data-code="'+optionCode+'">'+
								'<div class="'+classz+'"></div>'+
								'<div class="position-relative">'+
								'<div class="edit-area edit-child-element" contenteditable="true" data-value="">'+
								'<div style="width:300px" class="edit-area edit-child-element" contenteditable="true" data-value="">'+
								'选项'+prevItemCount+
								'</div>'+
								'</div>'+
								'</li>';
								'</div>';
                        if(label == 5 && classz == "div-radio-img"){
                            item += '<div style="float:right"><input type="text" placeholder="填写分值" class="edit-area edit-child-element fieldValue" contenteditable="true" data-value=""></div>';
                        }
                        item += '</div></li>';
						appendItem.append(item);
					}).on("click",".add-area .batch-add-choice",function(){//批量增加选项事件
						self.clearButtonsActive();
						var questionItem = $(this).closest(".topic-type-question");
						self.$divPatchDialog.find(".batch-choices").val("");//清空原来的值
						divPatchDialog = $.ligerDialog.open({
							title: "批量添加选项框",
							width: 320,
@ -288,11 +291,13 @@
									itemStr += '<li class="choice" data-input="0" data-input-required="0" data-code="'+optionCode+'">'+
											'<div class="'+classz+'"></div>'+
											'<div class="position-relative">'+
											'<div class="edit-area edit-child-element" contenteditable="true" data-value="">'+
											'<div style="width:300px" class="edit-area edit-child-element" contenteditable="true" data-value="">'+
												patchItemArr[i]+
											'</div>'+
											'</div>'+
											'</li>';
											'</div>';
                                    if(label == 5 && classz == "div-radio-img"){
                                        itemStr += '<div style="float:right"><input type="text" placeholder="填写分值" class="edit-area edit-child-element fieldValue" contenteditable="true" data-value=""></div>';
                                    }
                                    itemStr += '</div></li>';
								}
							}
							appendItem.append(itemStr);
@ -790,6 +795,19 @@
						})
					}).on("click","#save_btn",function(){//保存问题事件
						self.clearButtonsActive();
						var flag = false;
                        $(".fieldValue").each(function(index,item){
                            if($(".fieldValue").length != 0){
                                if($(this).val() == ''){
                                    flag = true;
                                    $.Notice.error('请输入分值');
                                    return false;
                                };
                            }
                        });
                        if(flag){
                            return false;
                        }
						if($("#question_box").find(".topic-type-question").length==0){
							$.Notice.success('当前没有问题,请添加后再保存!');
							return false;
@ -829,7 +847,11 @@
						success: function (result) {
							if (result.status == 200) {
								$.Notice.success(result.msg);
								location.href =  ctx + '/admin/surveyTemplate/initial';
								if(label == 5) {
                                    location.href = ctx + '/admin/surveyTemplate/initResult?templateCode=' + result.data.code + '&diseaseType='+ result.data.diseaseType+ '&mode=' + $("#inp_mode").val();
                                }else{
                                    location.href = ctx + '/admin/surveyTemplate/initial';
                                }
							} else {
								$.Notice.error(result.msg);
							}
@ -875,7 +897,7 @@
													'</div>'+
												'</div>'+
											'</div>';
						var optionHtml = '<ul class="question-choice">';
						var optionHtml = '<ul id="question-choice" class="question-choice">';
						var itemHtml = "";
						var addAreaHtml = "";
						var operateHtml = "";
@ -892,11 +914,14 @@
								itemHtml+='<li class="choice" data-input="0" data-input-required="0" data-code="'+optionCode+'">'+
												'<div class="'+imgClass+'"></div>'+
												'<div class="position-relative">'+
													'<div class="edit-area edit-child-element" contenteditable="true" data-value="">'+
													'<div style="width:300px" class="edit-area edit-child-element" contenteditable="true" data-value="">'+
													optionData[j] +
													'</div>'+
												'</div>'+
										  '</li>';
													'</div>';
                                if(label == 5 && type=="0"){
                                    itemHtml += '<div style="float:right"><input type="text" placeholder="填写分值" class="edit-area edit-child-element fieldValue" contenteditable="true" data-value=""></div>';
                                }
                                itemHtml += '</div></li>';
							}else{//问答题
								itemHtml = '<li class="choice" data-input="0" data-input-required="0" data-code="'+optionCode+'">'+
												'<div style="padding:10px 0px;">'+
@ -1002,6 +1027,7 @@
							var haveComment = optionData[j].haveComment;
							var optionIsRequired = optionData[j].isRequired;
							var content = optionData[j].content;
                            var score = optionData[j].score;
							if(optionData[j].questionCodeNext!="" && optionData[j].questionCodeNext!=undefined){
								options.push({optionItem:optionCode,questionCodeNext:optionData[j].questionCodeNext,questionSortNext:optionData[j].questionSortNext});
							}
@ -1021,12 +1047,15 @@
								itemHtml+='<li class="choice" data-input="'+optionData[j].isRequired+'" data-input-required="'+optionData[j].haveComment+'" data-code="'+optionCode+'">'+
										'<div class="'+imgClass+'"></div>'+
										'<div class="position-relative">'+
										'<div class="edit-area edit-child-element"  contenteditable="true">'+
										'<div style="width:300px" class="edit-area edit-child-element"  contenteditable="true">'+
										content +
										'</div>'+
										'</div>'+
										remark+
										'</li>';
                                        '</div>';
                                if(label == 5 && type=="0"){
                                    itemHtml += '<div style="float:right"><input type="text"  class="edit-area edit-child-element fieldValue" contenteditable="true" value="'+score+'"></div>';
                                }
                                itemHtml += '</div>'+
                                    remark+
                                    '</li>';
							}else{//问答题
								itemHtml = '<li class="choice" data-code="'+optionCode+'">'+
										'<div style="padding:10px 0px;">'+
@ -1112,6 +1141,8 @@
					var templateComment = $(".div-wenjuan-title").find(".div-template-comment").html();//问卷说明
					var labels = JSON.parse(templateData.labels);//上一个页面已勾选的标签值
					var labelsName = templateData.labelsName;//标签中文值
                    var organization = templateData.organization;//发布机构
                    var diseaseType = templateData.diseaseType;//疾病类型
					var topicTypeQuestion =   $("#question_box").find(".topic-type-question");
					for(var i=0;i<topicTypeQuestion.length;i++){
						var item = $(topicTypeQuestion[i]);
@ -1139,6 +1170,8 @@
								var haveComment = $(optionItem[j]).find(".other-content").length>0?1:0;//是否有选项说明(0没有 1有)
								var optionIsRequired =  $(optionItem[j]).find(".other-required").length>0?1:0;////选项说明是否必填(0否 1是)
								var content = $(optionItem[j]).find(".edit-child-element").html();//选项内容
                                // var score = document.getElementById("fieldValue").value;//选项分值
                                var score = $(optionItem[j]).find(".fieldValue").val();
								var optionSort = j+1;//单题内排序
								var optionCode = $(optionItem[j]).attr("data-code");
								var optionQuestionCodeNext = "";//选项的下一个跳转code
@ -1153,15 +1186,15 @@
									}
								}
								optionData.push({"haveComment": haveComment,"content": content,"isRequired": optionIsRequired,"sort": optionSort,"code":optionCode,"questionCodeNext":optionQuestionCodeNext,"questionSortNext":optionQuestionCodeSort});
								optionData.push({"haveComment": haveComment,"content": content,"isRequired": optionIsRequired,"sort": optionSort,"code":optionCode,"questionCodeNext":optionQuestionCodeNext,"questionSortNext":optionQuestionCodeSort,"score":score});
							}
						}
						questions.push({"title": title,"code": questionCode,"comment": comment,"questionType": questionType,"isRequired":isRequired,"minNum": minNum,"maxNum": maxNum,"sort": questionSort,"questionCodeNext": questionCodeNext,"questionSortNext":questionCodeSort,"options": optionData})
					}
					if($("#inp_mode").val()=="add"){
						resultData.push({title:templateName,comment:templateComment,labels:labels,questions:questions});
						resultData.push({organization:organization,title:templateName,comment:templateComment,labels:labels,questions:questions,diseaseType:diseaseType});
					}else{
						resultData.push({id:templateData.templateId,title:templateName,comment:templateComment,labels:labels,questions:questions});
						resultData.push({id:templateData.templateId,organization:organization,title:templateName,comment:templateComment,labels:labels,questions:questions,diseaseType:diseaseType});
					}
					return resultData;
				},
@ -1170,7 +1203,6 @@
					var resultHtml = "";
					var templateName = $(".div-wenjuan-title").find(".div-template-name").html();//问卷标题
					var templateComment = $(".div-wenjuan-title").find(".div-template-comment").html();//问卷说明
					var labels = JSON.parse(templateData.labels);//上一个页面已勾选的标签值
					var labelsName = templateData.labelsName;//标签中文值
					var resultData = self.getSaveingData();
					debugger
@ -1180,7 +1212,7 @@
							var titleData = Tquestions[j].title;//标题
							var questionCodeNext =  Tquestions[j].questionCodeNext;
							var questionCodeSort =  Tquestions[j].questionSortNext;
							if(questionCodeNext!=""){
							if(questionCodeNext != null){
								titleData = Tquestions[j].title+questionCodeSort;
							}
							var questionSort = Tquestions[j].sort;
@ -1220,9 +1252,10 @@
								var haveComment = optionData[k].haveComment;
								var optionIsRequired = optionData[k].isRequired;
								var content = optionData[k].content;
								var score = optionData[k].score;
								var optionquestionCodeNext =  optionData[k].questionCodeNext;
								var optionquestionCodeSort =  optionData[k].questionSortNext;
								if(optionquestionCodeNext!=""){
								if(optionquestionCodeSort!= null){
									content = optionData[k].content+optionquestionCodeSort;
								}
								if(questionType=="0" || questionType=="1"){//单选题或多选题
@ -1242,11 +1275,13 @@
												'<div class="'+imgClass+'"></div>'+
												'<div class="position-relative">'+
												'<div class="edit-area edit-child-element">'+
													content +
												'</div>'+
												'</div>'+
													remark+
											'</li>';
													content;
									if(label == 5 && questionType=="0"){
                                        itemHtml += '<span style="float:right;color: #5c80d2;">'+ score + '分</span>';
                                    }
                                    itemHtml += '</div></div>'+
                                                  remark+
											    '</li>';
								}else{//问答题
									itemHtml = '<li class="choice">'+
											'<div style="padding:10px 0px;">'+

Fichier diff supprimé car celui-ci est trop grand
+ 121 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_advice.jsp


+ 172 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_advice_js.jsp

@ -0,0 +1,172 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<link href="${ctx}/static/develop/lib/select2/select2.min.css" rel="stylesheet">
<script src="${ctx}/static/develop/lib/select2/select2.js"></script>
<script>
    (function ($, win) {
        $(function () {
            /* ************************** 变量定义 ******************************** */
            // 通用工具类库
            var Util = $.Util;
            var retrieve = null;
            var jValidation = $.jValidation;
            var addAdvice=$("#addAdvice").clone();
            var infoDialog=null
            //判断是否为选中评分筛查按钮
            var flag = 0;
            /* *************************** 函数定义 ******************************* */
            function pageInit() {
                retrieve.init();
            }
            /* *************************** 模块初始化 ***************************** */
            win.closeInfoDialog = function () {
                infoDialog.close();
                $("#addAdvice").remove();
                $('body').append(addAdvice)
            };
            retrieve = {
                    init: function () {
                        var templateCode = $("#inp_templateCode").val();
                        var diseaseType = $("#inp_diseaseType").val();
                        var mode = $("#inp_mode").val();
                        if(mode == "edit"){
                            $.ajax({
                                url: ctx + "/admin/surveyTemplateAdvice/adviceList",
                                method: "post",
                                dataType: "json",
                                async: false,
                                data: {templateCode: templateCode},
                                success: function (result) {
                                    if(result.data.length != 0){
                                        var str='';
                                        for(var i in result.data){
                                            str+='<li class="list-item" data-code="'+result.data[i].code+'">'+result.data[i].advice+'</li>'
                                        }
                                        $('.right-list').append(str);
                                    }
                                },
                                error: function (data) {
                                    $.Notice.error("系统异常,请联系管理员!");
                                }
                            })
                        };
                        function findByDiseaseType(){
                            $.ajax({
                                url: ctx + "/admin/surveyAdvice/findByDiseaseType",
                                method: "post",
                                dataType: "json",
                                async: false,
                                data: {diseaseType: diseaseType,templateCode: templateCode},
                                success: function (result) {
                                    console.log(result)
                                    if(result.data.length != 0){
                                        var str='';
                                        for(var i in result.data){
                                            str+='<li class="list-item" data-code="'+result.data[i].code+'">'+result.data[i].advice+'</li>'
                                        }
                                        $('.left-list').append(str);
                                    }
                                },
                                error: function (data) {
                                    $.Notice.error("系统异常,请联系管理员!");
                                }
                            });
                        };
                        findByDiseaseType();
                        (function bindEven(){
                            $('.tree-list').on('click','.list-item',function(){
                                $(this).toggleClass('active');
                            })
                        })();
                        $(".jintou img").on('click',function(){
                            shift($(this).attr('data-action'))
                        });
                        function shift(arr){
                            var data=arr.split(',');
                            var yuan='';
                            var quxiang=data[0];
                            var isAll=data[1] || false;
                            if(quxiang=='left'){
                                yuan='right';
                            }else{
                                yuan='left';
                            }
                            var _append=isAll?$('.'+yuan+'-list').children():$('.'+yuan+'-list').find('.active');
                            $('.'+quxiang+'-list').append(_append.removeClass('active'));
                        };
                       //新建建议
                        $('.create-new').on('click',function(){
                            addAdvice.show()
                            infoDialog = $.ligerDialog.open({
                                title: "创建新建议标签",
                                width: 400,
                                height: 300,
                                target: addAdvice[0].outerHTML
                            });
                            $('body').on("click","#save_btn",function(){//关闭弹窗事件
                                var advice=$('.advice-content')[1].value;
                                if(!advice){
                                    infoDialog.close();
                                }
                                $.ajax({
                                    url: ctx + "/admin/surveyAdvice/saveOrUpdate",
                                    method: "post",
                                    dataType: "json",
                                    async: false,
                                    data: {jsonData: JSON.stringify({advice:advice,diseaseType:diseaseType})},
                                    success: function (result) {
                                        if(result.status == 200){
                                            $('.left-list').append('<li class="list-item" data-code="'+result.data.code+'">'+advice+'</li>');
                                            infoDialog.close();
                                        } else {
                                            $.Notice.error(result.msg);
                                        }
                                    },
                                    error: function (data) {
                                        $.Notice.error("系统异常,请联系管理员!");
                                    }
                                });
                            })
                        });
                       //			保存筛选表
                        $('.submit-btn').on('click',function(){
                            var going = true;
                            var codeArr=[];
                            $('.right-list li').each(function(index,item){
                                if($('.right-list li').length != 0){
                                    codeArr[index]={};
                                    var code=$(this).data('code')+'';
                                    codeArr[index].adviceCode=code;
                                    codeArr[index].templateCode=templateCode;
                                }
                            });
                            if(codeArr.length != 0){
                                $.ajax({
                                    url: ctx + "/admin/surveyTemplateAdvice/saveOrUpdate",
                                    method: "post",
                                    dataType: "json",
                                    async: false,
                                    data: {jsonData:JSON.stringify(codeArr),templateCode:templateCode},
                                    success: function (result) {
                                        console.log(result)
                                        location.href = ctx + '/admin/surveyTemplate/initial';
                                    },
                                    error: function (data) {
                                        console.log(data)
                                    }
                                });
                            }
                        })
                    }
            }
            /* *************************** 页面初始化 **************************** */
            pageInit();
        });
    })(jQuery, window);
</script>

+ 8 - 5
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_list_js.jsp

@ -241,7 +241,7 @@
						var titleData = Tquestions[j].title;//标题
						var questionCodeNext =  Tquestions[j].questionCodeNext;
						var questionCodeSort =  Tquestions[j].questionSortNext;
						if(questionCodeNext!=""){
						if(questionCodeNext != null){
							titleData = Tquestions[j].title+questionCodeSort;
						}
						var questionSort = Tquestions[j].sort;
@ -281,9 +281,10 @@
							var haveComment = optionData[k].haveComment;
							var optionIsRequired = optionData[k].isRequired;
							var content = optionData[k].content;
							var score = optionData[k].score;
							var optionquestionCodeNext =  optionData[k].questionCodeNext;
							var optionquestionCodeSort =  optionData[k].questionSortNext;
							if(optionquestionCodeNext!=""){
							if(optionquestionCodeNext != null){
								content = optionData[k].content+optionquestionCodeSort;
							}
							if(questionType=="0" || questionType=="1"){//单选题或多选题
@ -303,9 +304,11 @@
										'<div class="'+imgClass+'"></div>'+
										'<div class="position-relative">'+
										'<div class="edit-area edit-child-element">'+
										content +
										'</div>'+
										'</div>'+
										content;
								if(score != null){
                                    itemHtml += '<span style="float:right;color: #5c80d2;">'+ score + '分</span>';
                                }
                                itemHtml +=	'</div></div>'+
										remark+
										'</li>';
							}else{//问答题

+ 90 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_result.jsp

@ -0,0 +1,90 @@
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/5 0005
  Time: 上午 11:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@ include file="../../head/page_head.jsp" %>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="http://172.19.103.72:8080/wlyy_admin/static/develop/lib/bootstrap/css/bootstrap.css" />
    <style type="text/css">
        .flex-box{display: -webkit-box;      /* OLD - iOS 6-, Safari 3.1-6 */         /* OLD - Firefox 19- (buggy but mostly works) */
            display: -ms-flexbox;      /* TWEENER - IE 10 */     /* NEW - Chrome */
            display: flex;-webkit-box-pack: center;-ms-flex-pack: center;justify-content: center;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}
        .flex-box-item{-webkit-box-flex: 1;      /* OLD - iOS 6-, Safari 3.1-6 */
            -moz-box-flex: 1;         /* OLD - Firefox 19- */
            -webkit-flex: 1;          /* Chrome */
            -ms-flex: 1;              /* IE 10 */
            width: 50%;               /* For old syntax, otherwise collapses. */
            flex: 1;                  /* NEW, Spec - Opera 12.1, Firefox 20+ */}
        .settings-content{padding-bottom: 40px;position: relative;}
        .page-title{font-size: 14px;font-weight: bold;padding: 10px 15px;border-bottom: 1px solid #ececec;margin-bottom: 20px;}
        .width100{width: 100%;}
        .mw100{max-width: 100px;}
        .h120{height: 120px!important;}
        .mr40{margin-left: 40px;}
        .mb20{margin-bottom: 20px;}
        .caozuo-btn{padding-top: 36px;padding-left: 0;}
        .caozuo-btn .btn{position: relative;}
        .caozuo-btn .btn+.btn{margin-top: 20px;}
        .result-row + .result-row{margin-top: 40px;}
        .plus-setting{display: inline-block;position: absolute;left: 70px;cursor: pointer;font-size: 18px;bottom: 10px;color: #fff;background-color: #2d9bd2;border-radius: 100%;width: 22px;height: 22px;line-height: 22px;text-align: center;}
        .xsyj{opacity: 0;position: absolute;left: 0;right: 0;top: 0;bottom: 0;}
        .xsyj i{display: none;}
        .xsyj:checked ~ i{width: 14px;position: absolute;right: 10px;top: 8px;height: 14px;display: inline-block;vertical-align: middle;background: url(http://172.19.103.72:8080/wlyy_admin/static/develop/images/yigouxuan_icon.png) center center / 100% 100% no-repeat;}
        .clear-fixed-buttom{height: 74px;}
        .submit-setting{position: fixed;height: 74px;line-height: 74px;left: 0;right: 0;bottom: 0;border-top: 1px solid #ececec;}
        .red-color{vertical-align: middle;color: red;}
        .red-prompt{position: absolute;bottom: 5px;left: 70px;right: 15px;margin-bottom: 0;}
        .plus-setting{display: inline-block;position: absolute;left: 70px;cursor: pointer;font-size: 18px;bottom: 30px;color: #fff;background-color: #2d9bd2;border-radius: 100%;width: 22px;height: 22px;line-height: 22px;text-align: center;}
        .settings-content{padding-bottom: 70px;position: relative;}
    </style>
</head>
<body>
<div class="c-container">
    <input type="hidden" id="inp_templateCode" value='${templateCode}'/>
    <input type="hidden" id="inp_diseaseType" value='${diseaseType}'/>
    <input type="hidden" id="inp_mode" value='${mode}'/>
    <p class="page-title">筛查结果设置</p>
    <div class="settings-content">
        <!--加号-->
        <span class="plus-setting">+</span>
        <p class="red-color red-prompt">null代表无上限</p>
        <div class="form-inline result-row clearfix">
            <div class="flex-box col-xs-10 fenzhi mb20">
                <span><span class="red-color">*</span>分值范围&nbsp;&nbsp;</span>
                <input type="text" class="form-control flex-box-item mw100 low_score">
                <span>&nbsp;&nbsp;~&nbsp;&nbsp;</span>
                <input type="text" class="form-control flex-box-item mw100 high_score">
                <span class="mr40"><span class="red-color">*</span>分析结果&nbsp;&nbsp;</span>
                <input type="text" class="form-control flex-box-item result"></div>
            <div class="col-xs-10 flex-box">
                <span style="align-self: flex-start;"><span class="red-color">*</span>筛查建议&nbsp;&nbsp;</span>
                <textarea rows="5" class="form-control flex-box-item h120 advice" placeholder="筛查建议"></textarea>
            </div>
            <div class="col-xs-2 caozuo-btn">
                <label class="btn btn-success width100">显示预警<input type="checkbox" class="xsyj"><i></i></label>
                <button class="btn btn-danger delete-btn width100">删除</button>
            </div>
        </div>
    </div>
    <div class="clear-fixed-buttom">
        <div class="submit-setting text-center">
            <button class="btn btn-primary submit-btn">保存筛选表</button>
        </div>
    </div>
</div>
</body>
<%@ include file="../../head/page_foot.jsp" %>
<%@ include file="template_result_js.jsp" %>
</html>

+ 134 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/questionnaire/template/template_result_js.jsp

@ -0,0 +1,134 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<link href="${ctx}/static/develop/lib/select2/select2.min.css" rel="stylesheet">
<script src="${ctx}/static/develop/lib/select2/select2.js"></script>
<script>
    (function ($, win) {
        $(function () {
            /* ************************** 变量定义 ******************************** */
            // 通用工具类库
            var Util = $.Util;
            var retrieve = null;
            var jValidation = $.jValidation;
            //判断是否为选中评分筛查按钮
            var flag = 0;
            /* *************************** 函数定义 ******************************* */
            function pageInit() {
                retrieve.init();
            }
            /* *************************** 模块初始化 ***************************** */
            retrieve = {
                init: function () {
                    var self = this;
                    var templateCode = $("#inp_templateCode").val();
                    var diseaseType = $("#inp_diseaseType").val();
                    var mode = $("#inp_mode").val();
                    // var ctx = "http://192.168.131.115:8180"
                    var cloneDiv = $('.result-row')[0].cloneNode(true);
                    if(mode == "edit"){
                        //这边加入提示动画
                        $.ajax({
                            url: ctx + "/admin/surveyTemplateResult/findByTemplateCode",
                            method: "post",
                            dataType: "json",
                            async: true,//同步获取
                            data: {"templateCode":templateCode},
                            success: function (res) {
                                var str='';
                                if(res.data && res.data.length){
                                    for(var i in res.data){
                                        var result=res.data[i];
                                        var checked="checked='checked'";
                                        str+='<div class="form-inline result-row clearfix"><input type="hidden" class="form-control flex-box-item mw100 id" value="'+result.id+'">\
                                            <div class="flex-box col-xs-10 fenzhi mb20">\
                                                <span><span class="red-color">*</span>分值范围&nbsp;&nbsp;</span>\
                                                <input type="text" class="form-control flex-box-item mw100 low_score" value="'+result.lowScore+'">\
                                                <span>&nbsp;&nbsp;~&nbsp;&nbsp;</span>\
                                                <input type="text" class="form-control flex-box-item mw100 high_score" value="'+result.highScore+'">\
                                                <span class="mr40"><span class="red-color">*</span>分析结果&nbsp;&nbsp;</span>\
                                                <input type="text" class="form-control flex-box-item result" value="'+result.result+'"></div>\
                                            <div class="col-xs-10 flex-box">\
                                                <span style="align-self: flex-start;"><span class="red-color">*</span>筛查建议&nbsp;&nbsp;</span>\
                                                <textarea rows="5" class="form-control flex-box-item h120 advice" placeholder="筛查建议">'+result.advice+'</textarea>\
                                            </div>\
                                            <div class="col-xs-2 caozuo-btn">\
                                                <label class="btn btn-success width100">显示预警<input type="checkbox" class="xsyj" '+(result.warning==1?checked:"")+'><i></i></label>\
                                                <button class="btn btn-danger delete-btn width100">删除</button>\
                                            </div>\
                                        </div>';
                                    }
                                }
                                str && $('.result-row').remove();
                                str && $('.settings-content').append(str);
                            },
                            error: function (data) {
                                console.log(data)
//							$.Notice.error("系统异常,请联系管理员!");
                            }
                        });
                    }
                    var submitArr = [];
                    $('.plus-setting').on('click', function () {
                        var clone = cloneDiv.cloneNode(true);
                        $('.settings-content').append(clone);
                    })
                    $('.submit-btn').on('click', function () {
                        var going = true;
                        $('.result-row').each(function (index, item) {
                            if (going) {
                                var low_score = $(this).find('.low_score').val();
                                var high_score = $(this).find('.high_score').val();
                                var advice = $(this).find('.advice').val();
                                var id = $(this).find('.id').val();
                                if (!low_score || !high_score || !advice) {
                                    going = false;
                                    alert('信息未填写完整')
                                    $('body,html').animate({
                                        scrollTop: 0
                                    }, 500);
                                }
                                submitArr[index] = {};
                                submitArr[index]['lowScore'] = $(this).find('.low_score').val();
                                submitArr[index]['highScore'] = $(this).find('.high_score').val();
                                submitArr[index]['result'] = $(this).find('.result').val();
                                submitArr[index]['advice'] = $(this).find('.advice').val();
                                submitArr[index]['warning'] = $(this).find('.xsyj').prop('checked') ? 1 : 0;
                                submitArr[index]['templateCode'] = templateCode;
                                if(id != null){
                                    submitArr[index]['id'] = id;
                                }
                            }
                        })
                        if (!going) return ;
                        $.ajax({
                            url: ctx + "/admin/surveyTemplateResult/save",
                            method: "post",
                            dataType: "json",
                            async: false,
                            data: {"jsonData":JSON.stringify(submitArr),templateCode:templateCode},
                            success: function (result) {
                                console.log(result);
                                location.href =  ctx + '/admin/surveyTemplateAdvice/initial?diseaseType='+diseaseType+'&templateCode=' + templateCode + '&mode=' + mode;
                            },
                            error: function (data) {
                                console.log(data)
//							$.Notice.error("系统异常,请联系管理员!");
                            }
                        });
                    });
                    (function(){
                        $('.settings-content').on('click','.delete-btn', function () {
                            $(this).parents('.result-row').remove();
                        });
                    })();
                },
            }
                    /* *************************** 页面初始化 **************************** */
        pageInit();
    });
    })(jQuery, window);
</script>

+ 13 - 8
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/static_wechat.jsp

@ -13,20 +13,24 @@
            <div style="position:relative;display:inline;left:10px;top:8px;white-space:nowrap;text-align:center;background-color:#ffffff;font-weight:bold">微信关注量详情</div>
            <div style="height:auto;width:auto;border:#dde7f1 1px solid;">
                <div class="m-form-group f-mt10" id="we_export_div">
                    <div class="m-form-control f-ml15" style="display: none">
                        <input type="text" id="inp_device_name" placeholder="请选择城市" class="f-ml10"/></div>
                    <div class="m-form-control f-ml15 essential" style="display: none">
                        <input type="text" id="inp_device_name" placeholder="请选择城市" class="required useTitle f-ml10" required-title="城市不能为空"/>
                    </div>
                    <br>
                    <div class="m-form-control f-ml15 essential">
                        <input type="text" id="inp_categoryCode" placeholder="请选择市区" class="required useTitle f-ml10" required-title="市区不能为空" />
                    </div>
                    <div class="m-form-control f-ml15">
                    <input type="text" id="inp_categoryCode" placeholder="请选择市区" class="f-ml10"/>
                    <br>
                    <div class="m-form-control f-ml15 essential">
                        <input type="text" id="inp_hos" placeholder="请选择机构" class="required useTitle f-ml10" required-title="机构不能为空"/>
                    </div>
                    <br>
                    <div class="m-form-control f-ml15">
                    <input type="text" id="inp_hos" placeholder="请选择机构" class="f-ml10"/>
                    <div class="m-form-control f-ml15 essential">
                        <input type="text" id="inp_att" placeholder="请选择关注状态" class="required useTitle f-ml10" required-title="关注状态不能为空"  />
                    </div>
                    <br>
                    <div class="m-form-control f-ml15">
                    <input type="text" id="inp_att" placeholder="请选择关注状态" class="f-ml10"/>
                    <div class="m-form-control f-ml15 essential">
                        <input type="text" id="inp_signSource" placeholder="请选择签约来源" class="required useTitle f-ml10" required-title="签约来源不能为空" />
                    </div>
                    <br>
                    <div id="export_list" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
@ -37,6 +41,7 @@
                </div>
            </div>
        </div>
    </div>
        <div style="font-family:微软雅黑;font-size:Small;display:block;clear:left;padding:0;margin:0;margin-left: 5px">
            <div style="position:relative;display:inline;left:10px;top:8px;white-space:nowrap;text-align:center;background-color:#ffffff;font-weight:bold">社区微信关注率</div>

+ 25 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/static_wechat_js.jsp

@ -15,6 +15,7 @@
            // 通用工具类库
            var retrieve = null;
            var inpStarDate = null,inpEndDate = null;
            var jValidation = $.jValidation;
            retrieve = {
                url: {
@ -35,6 +36,7 @@
                $inpStatus:$('#inp_status'),//状态
                $inpStarDate: $('#inp_star_date'),
                $inpEndDate: $('#inp_end_date'),
                $signSource: $('#inp_signSource'),//签约来源
                dnc: null,
                ccc: null,
@ -72,6 +74,15 @@
                        valueField: 'statusId',
                    });
                    //签约来源拉框
                    retrieve.signSourceBox = $('#inp_signSource').ligerComboBox({
                        width: 150,
                        data: [
                            {text: '社区签约', id: '1'},
                            {text: '移动签约', id: '2'},
                        ],
                        initIsTriggerEvent: false,
                    });
                    this.bindEvents();
@ -154,6 +165,13 @@
                    }
                },
                bindEvents: function () {
                    var validator = new jValidation.Validation($("#we_export_div"), {
                        immediate: true, onSubmit: false,
                        onElementValidateForAjax: function (elm) {
                        }
                    });
                    var me = this;
                    //城市下拉
                    me.$inpDeviceName.on( 'change', function () {
@ -169,6 +187,9 @@
                    });
                    //关注量详情导出
                    me.$btnExportList.on('click',function () {
                        if (!validator.validate()) {
                            return;
                        }
                        //定义一个form表单
                        var myform = $("<form></form>");
                        myform.attr('method','post')
@ -186,10 +207,14 @@
                        var attention = $("<input type='hidden' name='attention' />")
                        attention.attr('value',$("#inp_att_val").val());
                        //签约来源
                        var signSource = $("<input type='hidden' name='signSource' />")
                        signSource.attr('value',$("#inp_signSource_val").val());
                        myform.append(town);
                        myform.append(hospital);
                        myform.append(attention);
                        myform.append(signSource);
                        myform.appendTo('body').submit(); //must add this line for higher html spec
                    });

+ 2 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -345,6 +346,7 @@ public class QrCodeController extends WeixinBaseController {
        }
    }
    /**
     * 下载所有医生的二维码图片
     *

+ 23 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -901,4 +901,27 @@ public class DateUtil {
		Timestamp nousedate = new Timestamp(date.getTime());
		return nousedate;
	}
	/**
	 * 获取周一
	 * @return
	 */
	public static String getSundayOfThisDate(Date date) {
		SimpleDateFormat df2 = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		return df2.format(getSundayOfThisDateToDate(date));
	}
	/**
	 * 得到本周周日
	 *
	 * @return yyyy-MM-dd
	 */
	public static Date getSundayOfThisDateToDate(Date date) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 7);
		return c.getTime();
	}
}

+ 9 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java

@ -11,16 +11,21 @@ import java.util.List;
 * Created by zhangdan on 2018/7/2.
 */
public interface SurveyScreenResultDao extends PagingAndSortingRepository<SurveyScreenResult, Long> {
    @Query("select surveyScreenResult from SurveyScreenResult surveyScreenResult where surveyScreenResult.code=?1")
    SurveyScreenResult getSurveyScreenResultByCode(String code);
    @Query(nativeQuery = true, value = "SELECT * FROM `wlyy_survey_screen_result` WHERE template_code=?1 ORDER BY czrq DESC LIMIT 1")
    List<SurveyScreenResult> findNewOneByTemplateCode(String templateCode);
    @Query(nativeQuery = true, value = "SELECT * FROM `wlyy_survey_screen_result` WHERE template_code=?1 and patient_code = ?2 and source=1 ORDER BY czrq DESC LIMIT 1")
    List<SurveyScreenResult> findNewOneByTemplateCode(String templateCode,String patientCode);
    @Query("select a from  SurveyScreenResult a where a.parentCode=?1 and a.templateCode=?2")
    List<SurveyScreenResult> getByPatientCodeAndTemplateCode(String patientCode,String templateCode);
    @Query("select a from  SurveyScreenResult a where a.patientCode=?1 and a.templateCode=?2 and a.source=?3")
    List<SurveyScreenResult> getByPatientCodeAndTemplateCode(String patientCode,String templateCode,int source);
    @Modifying
    @Query("update SurveyScreenResult s set s.isAgain=0 where s.code=?1")
    void updateNoAgain(String code);
    @Query("select a from  SurveyScreenResult a where a.reservationCode=?1")
    List<SurveyScreenResult> getByReservationCode(String reservationCode);
}

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

@ -6,13 +6,14 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.lang.annotation.Native;
import java.util.List;
/**
 * Created by zhangdan on 2018/7/4.
 */
public interface SurveyTemplateResultDao extends PagingAndSortingRepository<SurveyTemplateResult, Long> {
    @Query("select a from SurveyTemplateResult a where a.templateCode=?1 and a.lowScore<=?2 and a.highScore>=?2")
    @Query(value = "SELECT * FROM  wlyy_survey_template_result WHERE template_code =?1 AND IF(high_score IS NULL,low_score<=?2,low_score <= ?2 AND high_score >= ?2)",nativeQuery = true)
    SurveyTemplateResult getByTemplateCodeAndLowScoreAndHighScore (String template,int score);
}

+ 24 - 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) 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) 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) 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) 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' ")
@ -123,4 +123,26 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query(" select a from Message a where a.type=?2 and a.del='1' and a.read=1 and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findUnReadByReceiverAndType(String receiver,Integer type);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type = 16 order by a.czrq desc")
    List<Message> getSpecialistApply(String receiver,Integer read,String over);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 17 order by a.czrq desc")
    List<Message> getFamilyTransfer(String receiver);
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type = 18 order by a.czrq desc")
    List<Message> getFamilySign(String receiver);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 18 and a.read = 1")
    List<Message> selectFamilySign(String receiver,Pageable pageableRequest);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type = 17 order by a.czrq desc")
    List<Message> getFamilyTransferReadAndOver(String receiver,Integer read,String over);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type = ?4 order by a.czrq desc")
    List<Message> getSpecialistUntreated(String receiver,Integer read,String over,Pageable pageable,Integer type);
    @Query("select a from Message a where a.code = ?1")
    Message findByCode(String code);
}

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientRecordLogDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.patient;/**
 * Created by nature of king on 2018/7/12.
 */
import com.yihu.wlyy.entity.patient.PatientRecordLog;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author wangzhinan
 * @create 2018-07-12 15:02
 * @desc 取消关注记录
 **/
public interface PatientRecordLogDao extends PagingAndSortingRepository<PatientRecordLog, Long> {
}

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

@ -1812,9 +1812,9 @@ public class PatientInfoService extends BaseService {
        return patientList;
    }
    public List<Map<String,Object>> getPatientSignByDoctor(int pageNo,int pageSize,String keyWord,String doctor)throws Exception{
    public List<Map<String,Object>> getPatientSignByDoctor(int pageNo,int pageSize,String keyWord,String doctor,long teamCode)throws Exception{
        int start = (pageNo-1)*pageSize;
        String sql = "SELECT `name`,patient,mobile,idcard,openid FROM wlyy_sign_family WHERE `status`>0 AND (doctor='"+doctor+"' OR doctor_health='"+doctor+"')";
        String sql = "SELECT `name`,patient,mobile,idcard,openid FROM wlyy_sign_family WHERE `status`>0 AND (doctor='"+doctor+"' OR doctor_health='"+doctor+"') and admin_team_code = "+teamCode;
        if (StringUtils.isNotEmpty(keyWord)){
            sql += " and name LIKE '%"+keyWord+"%'";
        }
@ -1822,7 +1822,7 @@ public class PatientInfoService extends BaseService {
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        for (Map<String,Object> map : list){
            String idcard = String.valueOf(map.get("idcard"));
            map.put("sex",IdCardUtil.getSexForIdcard(idcard));
            map.put("sex",IdCardUtil.getSexForIdcard_new(idcard));
            map.put("age",IdCardUtil.getAgeForIdcard(idcard));
            /*String healthSql ="SELECT value1,value2 FROM device.wlyy_patient_health_index WHERE user='"+String.valueOf(map.get("patient"))+"' AND type=3 ORDER BY record_date DESC LIMIT 1";
            List<Map<String,Object>> healthMapList = jdbcTemplate.queryForList(healthSql);

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -1167,7 +1167,7 @@ public class PatientDeviceService extends BaseService {
    public Map<String,Object> getDeviceByDeviceSn(String deviceSn)throws Exception {
        Map<String,Object> map  = new HashedMap();
        String sql = "SELECT d.id,d.device_name deviceName,d.device_model deviceMode,d.sim,e.is_multi_user isMultiUser,e.category_code as deviceType,e.multi_user multiUser,e.id as device_id FROM device.wlyy_devices d LEFT JOIN wlyy.dm_device e ON d.device_model = e.model WHERE d.device_code='"+deviceSn+"'";
        String sql = "SELECT d.id,d.device_name deviceName,d.device_model deviceMode,d.sim,CAST(e.is_multi_user AS UNSIGNED INTEGER) isMultiUser,e.category_code as deviceType,e.multi_user multiUser,e.id as device_id FROM device.wlyy_devices d LEFT JOIN wlyy.dm_device e ON d.device_model = e.model WHERE d.device_code='"+deviceSn+"'";
        List<Map<String,Object>> mapSqlList = jdbcTemplate.queryForList(sql);
        if (mapSqlList!=null && mapSqlList.size()>0){
            map = mapSqlList.get(0);

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

@ -1120,6 +1120,18 @@ public class SignPatientLabelInfoService extends BaseService {
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease", p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition", p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                String deviceSql = "select group_concat(category_code) deviceType FROM wlyy_patient_device where user ='"+p.getCode()+"'";
                List<Map<String,Object>> deviceMapList = jdbcTemplate.queryForList(deviceSql);
                if (deviceMapList!=null && deviceMapList.size()>0){
                    //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                    json.put("deviceType",deviceMapList.get(0).get("deviceType")==null?"":deviceMapList.get(0).get("deviceType"));
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.message;
import com.alibaba.fastjson.JSONArray;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.message.Message;
@ -15,7 +16,6 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.IdCardUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -134,7 +134,7 @@ public class MessageService extends BaseService {
        // 体征指标未读消息总数
        Integer healthIndex = messageDao.amountUnreadHealthByReceiver(doctor);
        JSONObject indexJson = new JSONObject();
        indexJson.put("amount", healthIndex);
        indexJson.put("l", healthIndex);
        if (healthIndex > 0) {
            PageRequest pageRequest = new PageRequest(0, 1);
            List<Message> msgs = messageDao.amountUnreadHealthLastByReceiver(doctor, pageRequest);
@ -224,6 +224,26 @@ public class MessageService extends BaseService {
            deviceMesJson.put("amount", 0);
        }
        //居民签约申请
        List<Message> familyList = messageDao.getFamilySign(doctor);
        JSONObject familyMesJson = new JSONObject();
        JSONArray array = new JSONArray();
        if (familyList != null && familyList.size() > 0) {
            familyMesJson.put("amount", familyList.size());
            JSONObject  familyJson = new JSONObject();
            familyJson.put("title", familyList.get(0).getTitle());
            familyJson.put("type", familyList.get(0).getType());
            familyJson.put("msg", "您有"+familyList.size()+"个居民申请共管服务!");
            familyJson.put("msgTime", DateUtil.dateToStrLong(familyList.get(0).getCreateTime()));
            familyJson.put("relationCode",familyList.get(0).getRelationCode());
            familyJson.put("reason",familyList.get(0).getReason());
            familyMesJson.put("lastMessage", familyJson);
        }else{
            familyMesJson.put("amount", 0);
        }
        JSONObject json = new JSONObject();
        json.put("imMsgCount", getImMsgAmount(doctor));//IM消息数量
        json.put("sign", signJson);//签约数
@ -233,6 +253,7 @@ public class MessageService extends BaseService {
        json.put("callService", callServiceMesJson);//协同服务消息
        json.put("articleCheck", articleMesJson);//健康文章审核消息
        json.put("deviceUnbind",deviceMesJson);//设备解绑消息
        json.put("familyList",familyMesJson);//居民签约申请
        return json;
    }
@ -788,4 +809,97 @@ public class MessageService extends BaseService {
        jsonObject.put("deviceType",String.valueOf(deviceMap.get("deviceType")));
        return  jsonObject;
    }
    /**
     * 待处理状态
     *
     * @param doctor 医生code
     * @return
     */
    public JSONObject selectUntreated(String doctor){
        //专科医生签约平台
        List<Message> specialist = messageDao.getSpecialistApply(doctor,1,"1");
        JSONObject specialistJson = new JSONObject();
        if (specialist != null && specialist.size() != 0){
            specialistJson.put("amount", specialist.size());
            JSONObject specialistObject = new JSONObject();
            specialistObject.put("title", specialist.get(0).getTitle());
            specialistObject.put("type", specialist.get(0).getType());
            specialistObject.put("msg", "您有"+specialist.size()+"个居民申请共管服务");
            specialistObject.put("msgTime", DateUtil.dateToStrLong(specialist.get(0).getCreateTime()));
            specialistObject.put("relationCode",specialist.get(0).getRelationCode());
            specialistJson.put("specialist",specialistObject);
        }
        //家庭医生转诊
        List<Message> familyList = messageDao.getFamilyTransferReadAndOver(doctor,1,"1");
        JSONObject familyJson = new JSONObject();
        if (familyList != null && familyList.size() != 0){
            familyJson.put("amount", familyList.size());
            JSONObject familyObject = new JSONObject();
            familyObject.put("title", familyList.get(0).getTitle());
            familyObject.put("type", familyList.get(0).getType());
            familyObject.put("msg", "您有"+familyList.size()+"个居民筛查转诊通知");
            familyObject.put("msgTime", DateUtil.dateToStrLong(familyList.get(0).getCreateTime()));
            familyObject.put("relationCode",familyList.get(0).getRelationCode());
            familyJson.put("familyList",familyObject);
        }
        JSONObject object = new JSONObject();
        object.put("count",familyList.size()+specialist.size());
        object.put("unTreatedCount",familyList.size()+specialist.size());
        object.put("messageCount",0);
        object.put("dialogueCount",0);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("MsgCount",object);
        jsonObject.put("specialist",specialistJson);
        jsonObject.put("familyList",familyJson);
        return jsonObject;
    }
    /**
     * 获取签约居民申请消息列表
     *
     * @param receiver 接收者
     * @param page 页码
     * @param size 分页大小
     * @return
     * @throws Exception
     */
    public List<Message> getFamilySign(String receiver,Integer page, Integer size) throws Exception{
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "read","over","createTime");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, size, sort);
        return messageDao.selectFamilySign(receiver,pageRequest);
    }
    /**
     * 获取待处理的接口
     *
     * @param message {}
     * @param page 页码
     * @param size 分页大小
     * @return
     * @throws Exception
     */
    public List<Message> getSpecialistUnTreated(Message message, Integer page, Integer size) throws Exception{
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "read","over","createTime");
        // 分页信息
        Pageable pageRequest = new PageRequest(page - 1, size, sort);
        return messageDao.getSpecialistUntreated(message.getReceiver(),message.getRead(),message.getOver(),pageRequest,message.getType());
    }
}

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

@ -47,6 +47,7 @@ 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.apache.commons.lang3.time.DateUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -1530,7 +1531,7 @@ public class SignWebService extends BaseService {
                    //发送短信
                    String mobile = (String) signFamily.get("mobile");
                    if (StringUtils.isNotBlank(mobile)) {
                        smsService.sendMsg(mobile, name + "您好!您的家庭医生将于6月30日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                        smsService.sendMsg(mobile, name + "您好!您的家庭医生签约到期时间为"+ DateUtil.getNowYear()+"年6月30号,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                    }
                }
@ -1592,7 +1593,7 @@ public class SignWebService extends BaseService {
                "  wlyy_sign_family a " +
                " WHERE " +
                "  a.patient = t.patient " +
                " AND a.status>0  " +
                " AND a.status>=0  " +
                " AND a.sign_year = '" + DateUtil.getSignYear() + "' " +
                ")";
@ -1651,7 +1652,7 @@ public class SignWebService extends BaseService {
                    //发送短信
                    String mobile = (String) signFamily.get("mobile");
                    if (StringUtils.isNotBlank(mobile)) {
                        smsService.sendMsg(mobile, name + "您好!您的家庭医生将于6月30日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                        smsService.sendMsg(mobile, name + "您好!您的家庭医生签约到期时间为"+ DateUtil.getNowYear()+"年6月30号,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                    }
                }
@ -2090,15 +2091,14 @@ public class SignWebService extends BaseService {
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, boolean isFollowWeChat,Integer page, Integer pageSize) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid,p.photo," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus,c.disease " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " LEFT JOIN (select patient,group_concat(label) disease,sum(label) lablesum from wlyy_sign_patient_label_info where label_type = 3 and status=1 GROUP BY patient) c on t.patient = c.patient " +
                " WHERE t.doctor ='" + doctor + "' AND t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 ");
        if(isFollowWeChat){
            sql.append(" AND p.openid IS NOT NULL AND p.openid <>'' order by p.standard_status DESC ,p.disease_condition DESC,c.lablesum DESC DESC LIMIT " + page * pageSize + "," + pageSize);
            sql.append(" AND p.openid IS NOT NULL AND p.openid <>'' order by p.standard_status DESC ,p.disease_condition DESC LIMIT " + page * pageSize + "," + pageSize);
        }else{
            sql.append(" order by p.standard_status DESC ,p.disease_condition DESC,c.lablesum DESC,p.openid DESC LIMIT " + page * pageSize + "," + pageSize);
            sql.append(" order by p.standard_status DESC ,p.disease_condition DESC,p.openid DESC LIMIT " + page * pageSize + "," + pageSize);
        }
        
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
@ -2296,7 +2296,7 @@ public class SignWebService extends BaseService {
            //发送短信
            String mobile = p.getMobile();
            if (StringUtils.isNotBlank(mobile)) {
                smsService.sendMsg(mobile, name + "您好!您的家庭医生将于6月30日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                smsService.sendMsg(mobile, name + "您好!您的家庭医生签约到期时间为"+ DateUtil.getNowYear()+"年6月30号,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                patientSetReminFlag(patientCode);
                return 2;
            }

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

@ -792,6 +792,15 @@ public class StatisticsESService {
        String filesize = df.format(size);
        return filesize + "%";
    }
    public int getRangeNum(int first, int second, int i) {
        if (second == 0 && first > 0) {
            return 100;
        } else if (second == 0 && first == 0) {
            return 0;
        }
        float size = (float) (first * 100) / second;
        return (int)(size*100);
    }
    public Double getRange2(int first, int second, int i) {
        if (second == 0 && first > 0) {
@ -5397,11 +5406,13 @@ public class StatisticsESService {
        return saveModel.getResult2().longValue();
    }
    public Map<String, Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year, String deviceType) throws Exception {
    public Map<String, Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year, String deviceType,int sortType) throws Exception {
        String index_85 = "85";//设备发放量统计指标
        String index_86 = "86";//设备绑定量统计指标
        String index_87 = "87";//设备使用量统计指标
        String index_88 = "88";//设备异常数据24H统计指标
        String index_96 = "96";//设备本周使用量
        String index_97 = "97";//设备本周使用量
        //String lastDate = year + "-06-30";
        //String timeKey = elasticsearchUtil.getQuotaTime();
        String timeKey = DateUtil.getStringDateShort();//当前时间
@ -5410,13 +5421,15 @@ public class StatisticsESService {
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        Map<String, Object> resultMap = new HashedMap();
        DecimalFormat df = new DecimalFormat("0.00");
        List<Map<String, Object>> resultList = new ArrayList<>();
        SaveModel grantSaveModel = null;
        SaveModel bindingSaveModel = null;
        List<SaveModel> startUseSaveModel = null;
        List<SaveModel> endUseSaveModel = null;
//        List<SaveModel> startUseSaveModel = null;
//        List<SaveModel> endUseSaveModel = null;
        SaveModel useSaveModel = null;
        SaveModel anomalySaveModel = null;
        SaveModel anomalyCountSaveModel = null;
        String allCountSql = "";
        String anomalyCountSql = "";
        String useCountSql = "";
@ -5436,11 +5449,13 @@ public class StatisticsESService {
                grantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer");
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer");
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血压%' " + areaCondition;
                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=1 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=1 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "1");
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "hemopiezometer");
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_97, SaveModel.timeLevel_DDL, "hemopiezometer");
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                break;
@ -5449,11 +5464,13 @@ public class StatisticsESService {
                grantSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer");
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer");
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where device_name like '%血糖%' " + areaCondition;
                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=2 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1 and p.type=2 and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL, "2");
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "glucometer");
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_97, SaveModel.timeLevel_DDL, "glucometer");
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                break;
@ -5463,8 +5480,10 @@ public class StatisticsESService {
                bindingSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_86, SaveModel.timeLevel_DDL);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_88, SaveModel.timeLevel_DDL);
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 " + areaCondition;
                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1  and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1  and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL);
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_97, SaveModel.timeLevel_DDL);
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
                allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "", low_level);
@ -5490,14 +5509,16 @@ public class StatisticsESService {
//        Double startTotalUseAccount = startUseSaveModel.size() > 0 ? startUseSaveModel.get(0).getResult1() : 0.0;
//        Double endTotalUseAccount = endUseSaveModel.size() > 0 ? endUseSaveModel.get(0).getResult1() : 0.0;
//        Double totalUseAccount = endTotalUseAccount-startTotalUseAccount;
        Integer useCount = jdbcTemplate.queryForObject(useCountSql, Integer.class);
//        Integer useCount = jdbcTemplate.queryForObject(useCountSql, Integer.class);
        Integer useCount = useSaveModel!=null?useSaveModel.getResult1().intValue():0;
        resultMap.put("totalUse", useCount);//本周使用量
        if (grantSaveModel.getResult1() > 0) {
            resultMap.put("totalUseRange", df.format(useCount.doubleValue() > 0.0 ? ((useCount.doubleValue()) / (grantSaveModel.getResult1() * 1.0000) * 100) : 0.0) + "%");//本周使用率
        } else {
            resultMap.put("totalUseRange", 0.0 + "%");//本周使用率
        }
        Integer totalAnomaly = jdbcTemplate.queryForObject(anomalyCountSql, Integer.class);
//        Integer totalAnomaly = jdbcTemplate.queryForObject(anomalyCountSql, Integer.class);
        Integer totalAnomaly = anomalyCountSaveModel!=null?anomalyCountSaveModel.getResult1().intValue():0;
        resultMap.put("totalAnomaly", totalAnomaly);//异常数据量
        resultMap.put("totalIntervene", anomalySaveModel.getResult1());//干预指导数
        if (totalAnomaly > 0) {
@ -5521,53 +5542,41 @@ public class StatisticsESService {
                }
            }
        }
        Map<String, SaveModel> bingdingMap = new HashMap<>();
        bindingAmountList.stream().forEach(one -> {
            if ("5".equals(low_level)) {
                bingdingMap.put(one.getTeam(), one);
            } else if ("4".equals(low_level)) {
                bingdingMap.put(one.getHospital(), one);
            } else if ("3".equals(low_level)) {
                bingdingMap.put(one.getTown(), one);
            }
        });
        //自建结果集
        resultList = getLowLevelMapKey(level, low_level, area);
        List<Map<String, Object>> resultList = getDeviceLowLevelMapKey(level, low_level, area,allMap,bingdingMap);
        if (resultList != null && resultList.size() > 0) {
            Map<String, SaveModel> bingdingMap = new HashMap<>();
            bindingAmountList.stream().forEach(one -> {
                if ("5".equals(low_level)) {
                    bingdingMap.put(one.getTeam(), one);
                } else if ("4".equals(low_level)) {
                    bingdingMap.put(one.getHospital(), one);
                } else if ("3".equals(low_level)) {
                    bingdingMap.put(one.getTown(), one);
                }
            });
            for (Map<String, Object> reMap : resultList) {
                reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
                int bindingAmount = 0;
                Integer allAmount = 0;
                //获取绑定数量
                if (bingdingMap != null && bingdingMap.size() > 0) {
                    SaveModel one = bingdingMap.get(reMap.get("code").toString());
                    if (one != null) {
                        bindingAmount = one.getResult2().intValue();
                    }
                }
                if (allMap != null && allMap.size() > 0) {
                    allAmount = allMap.get(reMap.get("code").toString());
                    if (allAmount == null) {
                        allAmount = 0;
                    }
                } else {
                }
                reMap.put("allNum", allAmount);
                reMap.put("bindingNum", bindingAmount);
                reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
            }
            if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
                translateTeamLeaderName(resultList);
            }
            //对结果进行排序
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = (int) o1.get("allNum");
                    int map2value = (int) o2.get("allNum");
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = 0;
                    int map2value = 0;
                    if(sortType==1){
                        map1value = (int) o1.get("allNum");
                        map2value = (int) o2.get("allNum");
                    }else if(sortType==2){
                        map1value = (int) o1.get("bindingNum");
                        map2value = (int) o2.get("bindingNum");
                    }else {
                        map1value = (int) o1.get("rateNum");
                        map2value = (int) o2.get("rateNum");
                    }
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
@ -5584,6 +5593,116 @@ public class StatisticsESService {
        }
    }
    /**
     * 获取下级统计key
     *
     * @param level
     * @param lowLevel
     * @param area
     * @return
     */
    public List<Map<String, Object>> getDeviceLowLevelMapKey(int level, String lowLevel, String area,Map<String, Integer> allMap,Map<String, SaveModel> bingdingMap) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (SaveModel.townLevel.equals(lowLevel)) {
            List<Town> towns = townDao.findByCityCode(area);
            if (towns != null) {
                for (Town town : towns) {
                    Map<String, Object> obj = new HashMap<>();
                    obj.put("code", town.getCode());
                    obj.put("name", town.getName());
                    obj.put("amount", "0");
                    obj = deviceRateList(obj,allMap,bingdingMap);
                    resultList.add(obj);
                }
            }
        } else if (lowLevel.equals("4")) {
            List<Town> towns = new ArrayList<>();
            if (SaveModel.cityLevel.equals(level + "")) {
                towns = townDao.findByCityCode(area);
            } else if (SaveModel.townLevel.equals(level + "")) {
                Town town = townDao.findByCode(area);
                if (town != null) {
                    towns.add(town);
                }
            }
            if (towns != null && towns.size() > 0) {
                for (Town town : towns) {
                    List<Hospital> hospitals = hospitalDao.findByTownCode(town.getCode());
                    for (Hospital hos : hospitals) {
                        if (hos.getCode().length() > 10) {
                            continue;
                        }
                        Map<String, Object> obj = new HashMap<>();
                        obj.put("code", hos.getCode());
                        obj.put("name", hos.getName());
                        obj.put("amount", "0");
                        obj = deviceRateList(obj,allMap,bingdingMap);
                        resultList.add(obj);
                    }
                }
            }
        } else if (SaveModel.teamLevel.equals(lowLevel)) {
            List<Hospital> hospitals = new ArrayList<>();
            if (level == 2) {
                hospitals = hospitalDao.findByCity(area);
            } else if (SaveModel.townLevel.equals(level + "")) {
                hospitals = hospitalDao.findByTownCode(area);
            } else {
                Hospital hos = hospitalDao.findByCode(area);
                if (hos != null) {
                    hospitals.add(hos);
                }
            }
            if (hospitals != null && hospitals.size() > 0) {
                for (Hospital hos : hospitals) {
                    if (hos.getCode().length() > 10) {
                        continue;
                    }
                    List<AdminTeam> teams = adminTeamDao.findByOrgCode(hos.getCode());
                    for (AdminTeam team : teams) {
                        Map<String, Object> obj = new HashMap<>();
                        obj.put("code", String.valueOf(team.getId()));
                        obj.put("name", team.getName());
                        obj.put("amount", "0");
                        obj = deviceRateList(obj,allMap,bingdingMap);
                        resultList.add(obj);
                    }
                }
            }
        }
        return resultList;
    }
    public Map<String, Object> deviceRateList(Map<String, Object> reMap,Map<String, Integer> allMap,Map<String, SaveModel> bingdingMap){
        reMap.put("amount", reMap.get("amount") != null ? Long.valueOf(reMap.get("amount").toString()) : 0L);
        int bindingAmount = 0;
        Integer allAmount = 0;
        //获取绑定数量
        if (bingdingMap != null && bingdingMap.size() > 0) {
            SaveModel one = bingdingMap.get(reMap.get("code").toString());
            if (one != null) {
                bindingAmount = one.getResult2().intValue();
            }
        }
        if (allMap != null && allMap.size() > 0) {
            allAmount = allMap.get(reMap.get("code").toString());
            if (allAmount == null) {
                allAmount = 0;
            }
        } else {
        }
        reMap.put("allNum", allAmount);
        reMap.put("bindingNum", bindingAmount);
        reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
        reMap.put("rateNum", getRangeNum(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
        return reMap;
    }
    //i健康活动统计1.4.8版本
    public Map<String, Object> statisticsActivity(String area, int level, int sort,String lowLevel,String slaveKey1) throws Exception {
        Map<String, Object> resultMap = new HashMap<>();

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

@ -4,15 +4,22 @@ 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.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.IdCardUtil;
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;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -22,6 +29,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -47,11 +55,49 @@ public class SurveyScreenResultService extends BaseService {
    @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;
    @Autowired
    private SurveyQuestionnaireOptionsDao surveyQuestionnaireOptionsDao;
    @Autowired
    private SurveyQuestionnaireDao surveyQuestionnaireDao;
    @Autowired
    private SurveyTemplateOptionsDao surveyTemplateOptionsDao;
    @Autowired
    private SurveyAnswersDao surveyAnswersDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private SurveyDimensionDao surveyDimensionDao;
    @Autowired
    private SurveyDimensionDetailDao surveyDimensionDetailDao;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -84,7 +130,7 @@ public class SurveyScreenResultService extends BaseService {
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("1",dealType)){
            //已预约
            sql += " AND ssr.order = 1";
            sql += " AND ssr.is_order = 1";
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("2",dealType)){
            //已跟踪
@ -92,14 +138,15 @@ public class SurveyScreenResultService extends BaseService {
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("3",dealType)){
            //已接诊
            sql += " AND ssr.order = 2";
            sql += " AND ssr.is_order = 2";
        }
        if (StringUtils.isNotEmpty(dealType) && StringUtils.equals("4",dealType)){
            //待处理
            sql +=" AND ssr.`order` = 0 AND ssr.following= 0";
            sql +=" AND ssr.is_order = 0 AND ssr.following= 0";
        }
        List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
        sql += " limit "+start+","+pageSize;
        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());
@ -115,9 +162,14 @@ public class SurveyScreenResultService extends BaseService {
     * @param labelType
     * @return
     */
    public List<SurveyTemplates> getScreenList(int pageNo,int pageSize,int labelType){
    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+" limit "+start+","+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+"%'";
        }
        sql += " order by st.create_time desc limit "+start+","+pageSize;
        List<SurveyTemplates> surveyTemplatesList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyTemplates.class));
        return surveyTemplatesList;
    }
@ -129,7 +181,7 @@ public class SurveyScreenResultService extends BaseService {
     * @param source
     * @param jsonData
     */
    public String saveScreenResult(String patientCode,String doctor,int isAgain,int source, JSONObject jsonData){
    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);
@ -138,6 +190,7 @@ public class SurveyScreenResultService extends BaseService {
        //解析json保存各种答案--获取一维数组
        JSONArray questions = jsonData.getJSONArray("questions");
        int totalScore = 0;
        for (int i = 0; i < questions.length(); i++) {
            //获取每一道题的信息
            JSONObject question = new JSONObject(questions.get(i).toString());
@ -148,7 +201,20 @@ public class SurveyScreenResultService extends BaseService {
                    JSONArray options = question.getJSONArray("options");
                    for (int j = 0; j < options.length(); j++) {
                        JSONObject option = new JSONObject(options.get(j).toString());
                        int score = Integer.parseInt(option.getString("score"));
                        /*String code = getCode();
                        String optionCode = option.get("optionCode").toString();
                        String comment = null;
                        int haveComment = 0;
                        if (option.has("comment")) {
                            comment = option.get("comment").toString();
                            haveComment = 1;
                        }
                        //保存到选择题答案表
                        SurveyOptionAnswers optionAnswer = new SurveyOptionAnswers(code, patientCode, surveyCode, qstCode, optionCode, comment, type, createTime,patient.getOpenid());
                        surveyOptionAnswersDao.save(optionAnswer);
                        //选择题修改统计表数量
                        surveyStatisticsDao.modifyAmount(surveyCode, qstCode, optionCode);*/
                        int score = option.getInt("score");
                        totalScore += score;
                    }
                }
@ -157,7 +223,7 @@ public class SurveyScreenResultService extends BaseService {
        //查询该筛查的结果设置
        SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode,totalScore);
        //更新上一条数据为不可再次评估
        List<SurveyScreenResult> surveyScreenResultList = surveyScreenResultDao.findNewOneByTemplateCode(surveyCode);
        List<SurveyScreenResult> surveyScreenResultList = surveyScreenResultDao.findNewOneByTemplateCode(surveyCode,patientCode);
        String lastCode = "";
        String originCode = "";
        if (surveyScreenResultList!=null && surveyScreenResultList.size()>0){
@ -184,7 +250,7 @@ public class SurveyScreenResultService extends BaseService {
        //来自医生发放和自我评估不一样来源
        if (source==1){
            surveyScreenResult.setDoctor(doctor);
        }else {
        }/*else {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            if (signFamily!=null && StringUtils.isNotEmpty(signFamily.getDoctor())){
                surveyScreenResult.setDoctor(signFamily.getDoctor());
@ -193,17 +259,18 @@ public class SurveyScreenResultService extends BaseService {
                surveyScreenResult.setDoctor(signFamily.getDoctorHealth());
            }
        }
        }*/
        surveyScreenResult.setPatientCode(patientCode);
        if (patient!=null){
            surveyScreenResult.setPatientName(patient.getName());
            surveyScreenResult.setOpenId(patient.getOpenid());
        }
        surveyScreenResult.setOrder(0);
        surveyScreenResult.setIsOrder(0);
        surveyScreenResult.setFollowing(0);
        surveyScreenResult.setOver(1);
        surveyScreenResult.setCzrq(new Date());
        surveyScreenResult.setIsAgain(1);
        surveyScreenResult.setIsEducate(0);
        surveyScreenResult.setScreenResultScore(totalScore);
        if (surveyTemplateResult!=null){
            surveyScreenResult.setScreenResultCode(surveyTemplateResult.getCode());
@ -211,8 +278,8 @@ public class SurveyScreenResultService extends BaseService {
            surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
        }
        surveyScreenResultDao.save(surveyScreenResult);
        managerQuestionnaireService.saveAnswer(patientCode,code,jsonData);
        return code;
    }
    public JSONObject getScreenResultDetail(String code)throws Exception{
@ -225,16 +292,17 @@ public class SurveyScreenResultService extends BaseService {
            json.put("message","没有改筛查结果!");
            return json;
        }
        /*String idcard = String.valueOf(infoMap.get("idcard"));
        infoMap.put("sex",IdCardUtil.getSexForIdcard(idcard));
        infoMap.put("age",IdCardUtil.getAgeForIdcard(idcard));*/
        String idcard = String.valueOf(infoMap.get("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 doctorCode = String.valueOf(infoMap.get("doctor"));
        String patientCode = String.valueOf(infoMap.get("patient_code"));
       /* Doctor doctor = doctorDao.findByCode(doctorCode);
        Doctor doctor = doctorDao.findByCode(doctorCode);
        if (doctor!=null){
            infoMap.put("level",doctor.getLevel());
            infoMap.put("doctorName",doctor.getName());
        }*/
        }
        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);
@ -244,7 +312,8 @@ public class SurveyScreenResultService extends BaseService {
        //题目和答案
        List<SurveyTemplateQuestions> questionList = surveyTemplateQuestionsDao.findById(templateCode);
        String sql = "SELECT soa.*,sto.score 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=?";
        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<>();
@ -255,13 +324,14 @@ public class SurveyScreenResultService extends BaseService {
                    map.put("option",option);
                }
            }
            json.put(surveyTemplateQuestions.getSort()+"",map);
            answerMap.put(surveyTemplateQuestions.getSort()+"",map);
        }
        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);
        int following = Integer.parseInt(String.valueOf(infoMap.get("following")));
        int order = Integer.parseInt(String.valueOf(infoMap.get("order")));
        int order = Integer.parseInt(String.valueOf(infoMap.get("is_order")));
        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+"'";
@ -279,7 +349,8 @@ public class SurveyScreenResultService extends BaseService {
                    surveyAdviceList.add(surveyAdviceDao.getByCode(adviceCode));
                }
            }
            resultMap.put("advice",surveyAdviceList);
            resultMap.put("doctorAdvice",surveyAdviceList);
            resultMap.put("doctorOtherAdvice",infoMap.get("other_advice"));
        }
        json.put("result",resultMap);
        return json;
@ -311,25 +382,28 @@ public class SurveyScreenResultService extends BaseService {
    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);
        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()).size();
            int count =  surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode,surveyTemplates.getCode(),2).size();
            sMap.put("myRecordCount",count);
            mapList.add(sMap);
        }
        map.put("screenList",mapList);
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result WHERE patient_code='"+patientCode+"' ORDER BY czrq DESC) a  GROUP BY a.template_code";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        map.put("result",surveyScreenResultList);
        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));
        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 st.`code`='"+templateCode+"' AND ssr.patient_code='"+patientCode+"' limit ?,?";
        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});
    }
@ -359,7 +433,7 @@ public class SurveyScreenResultService extends BaseService {
            if (surveyScreenResult.getFollowing()==1){
                followCount++;
            }
            if (surveyScreenResult.getOrder()==1){
            if (surveyScreenResult.getIsOrder()==1){
                orderCount++;
            }
            if (StringUtils.isNotEmpty(surveyScreenResult.getParentCode())){
@ -384,8 +458,570 @@ public class SurveyScreenResultService extends BaseService {
        return  resultMap;
    }
    public int getAmountByDoctor(String json,String doctorCode) {
        return getCountByDoctor(json,doctorCode).size();
    }
    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+"')";
        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 ";
        } else {
            str += " AND f.STATUS>0 AND p.`openid`IS NOT NULL AND p.`openid`!='')ff WHERE ff.CODE=s.sign_code ";
        }
        JSONArray service = jsonObject.getJSONArray("service");
        String ser = "";
        service:
        for (Object serv : service) {
            String type = serv.toString();
            switch (type) {
                case "0":
                    break service;
                default:
                    ser += " s.server_type= " + type;
                    break;
            }
            ser += " OR ";
        }
        if (StringUtils.isNotEmpty(ser)) {
            str += " AND ( " + ser.substring(0, ser.lastIndexOf("OR")) + " ) ";
        }
        str += " )tt WHERE lb.`status` = 1 AND lb.patient=tt.patient ";
        JSONArray healthCondition = jsonObject.getJSONArray("healthCondition");
        String healSql = "";
        String heal = "";
        health:
        for (Object health : healthCondition) {
            String type = health.toString();
            switch (type) {
                case "0":
                    break health;
                default:
                    heal += " lb.label= " + type;
                    break;
            }
            heal += " OR ";
        }
        if (StringUtils.isNotEmpty(heal)) {
            healSql = " (lb.label_type =2 AND ( " + heal.substring(0, heal.lastIndexOf("OR")) + " )  )";
        }
        JSONArray disease = jsonObject.getJSONArray("disease");
        String disSql = "";
        String dis = "";
        disea:
        for (Object disea : disease) {
            String type = disea.toString();
            switch (type) {
                case "0":
                    break disea;
                default:
                    dis += " lb.label= " + type;
                    break;
            }
            dis += " OR ";
        }
        if (StringUtils.isNotEmpty(dis)) {
            disSql= " (lb.label_type =3 AND ( " + dis.substring(0, dis.lastIndexOf("OR")) + " )  )";
        }
    public void getSpecialDoctorScreenList(String doctor,int type,int pageNo,int pageSize){
        if (StringUtils.isEmpty(heal) && StringUtils.isEmpty(dis)) {
            sql = str;
        } else if (StringUtils.isEmpty(heal) && StringUtils.isNotEmpty(dis)) {
            sql = str + " AND " +disSql;
        } else if (StringUtils.isNotEmpty(heal) && StringUtils.isEmpty(dis)) {
            sql = str + " AND " +healSql;
        } else if (StringUtils.isNotEmpty(heal) && StringUtils.isNotEmpty(dis)) {
            sql = str + " AND ( " + disSql +" OR " +healSql +" ) ";
        }
        System.out.println("=====query sql =======>>>>" + sql);
        List<String> patients = jdbcTemplate.queryForList(sql, String.class);
        return patients;
    }
    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
//        问卷信息
        String surveyCode = getCode();
        String surveyName = jsonStr.getString("surveyName");
        String surveyComment = jsonStr.getString("comment");
        String templateCode = null;
        String send = jsonStr.get("send").toString();
        String templateLabel = jsonStr.getString("label");
        int status = 1;
//        自主创建
        int useType = 1;
        if (!StringUtils.isEmpty(jsonStr.getString("templateCode"))) {
//          模板创建
            useType = 0;
            templateCode = jsonStr.getString("templateCode");
        }
//      获取调查对象
        JSONObject surveyTarget = jsonStr.getJSONObject("surveyTarget");
        //            0不限 1男 2女
//        int sex = Integer.parseInt(surveyTarget.get("sex").toString());
        JSONArray sex = surveyTarget.getJSONArray("sex");
        JSONArray disease = surveyTarget.getJSONArray("disease");
        JSONArray service = surveyTarget.getJSONArray("service");
        JSONArray healthCondition = surveyTarget.getJSONArray("healthCondition");
        int sexList = 0;
        for (Object se : sex) {
            JSONObject sexJson = new JSONObject(se.toString());
            int label = sexJson.getInt("label");
            sexList = label;
            if (label != 0) {
                String dimensionCode = surveyDimensionDao.findByName("性别");
                String dimensionDetailCode = getCode();
//            SurveyDimensionDetail surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, sex == 1 ? "男" : "女", sex, "性别", 1, surveyCode);
//            modify by wjj 2017.7.24 居民标签更改
                SurveyDimensionDetail surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, sexJson.getString("labelName"), label, "性别", 1, surveyCode);
                surveyDimensionDetailDao.save(surveyDimensionDetail);
//          保存到筛选表
                SurveyFilter surveyFilter = new SurveyFilter(getCode(), surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
        List servList = new ArrayList();
        for (Object serv : service) {
            JSONObject servJson = new JSONObject(serv.toString());
            int label = servJson.getInt("label");
            servList.add(label);
            if (label == 0) {
                break;
            } else {
//                       ===================================
                String dimensionCode = surveyDimensionDao.findByName("服务类型");
                String dimensionDetailCode = getCode();
                SurveyDimensionDetail surveyDimensionDetail = null;
                surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, servJson.getString("labelName"), label, "服务类型", 3, surveyCode);
               /* switch (Integer.parseInt(serv.toString())) {
//                1.普通人群 2.慢病人群 3.65岁以上人群
                    case 1:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "普通人群", 1, "服务类型", 3, surveyCode);
                        break;
                    case 2:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "慢病人群", 2, "服务类型", 3, surveyCode);
                        break;
                    case 3:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "65岁以上人群", 3, "服务类型", 3, surveyCode);
                        break;
                }
*/
                surveyDimensionDetailDao.save(surveyDimensionDetail);
                SurveyFilter surveyFilter = new SurveyFilter(getCode(), surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
        List healthList = new ArrayList();
        for (Object health : healthCondition) {
            JSONObject healthJson = new JSONObject(health.toString());
            int label = healthJson.getInt("label");
            healthList.add(label);
            if (label == 0) {
                break;
            } else {
                String dimensionCode = surveyDimensionDao.findByName("健康状况");
                String dimensionDetailCode = getCode();
                String surveyFilterCode = getCode();
                SurveyDimensionDetail surveyDimensionDetail = null;
                surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, healthJson.getString("labelName"), label, "健康状况", 4, surveyCode);
                /*switch (Integer.parseInt(health.toString())) {
//                1.健康人群 2.患病人群 3.高危人群 4.恢复期人群
                    case 1:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "健康人群", 1, "健康状况", 4, surveyCode);
                        break;
                    case 2:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "患病人群", 2, "健康状况", 4, surveyCode);
                        break;
                    case 3:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "高危人群", 3, "健康状况", 4, surveyCode);
                        break;
                    case 4:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "恢复期人群", 4, "健康状况", 4, surveyCode);
                        break;
                }*/
                surveyDimensionDetailDao.save(surveyDimensionDetail);
                SurveyFilter surveyFilter = new SurveyFilter(surveyFilterCode, surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
        List diseaList = new ArrayList();
        for (Object disea : disease) {
            JSONObject diseaJson = new JSONObject(disea.toString());
            int label = diseaJson.getInt("label");
            diseaList.add(label);
            if (label == 0) {
//                dise += ",";
                break;
            } else {
                String dimensionCode = surveyDimensionDao.findByName("疾病类型");
                String dimensionDetailCode = getCode();
                SurveyDimensionDetail surveyDimensionDetail = null;
                surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, diseaJson.getString("labelName"), label, "疾病类型", 2, surveyCode);
                /*switch (Integer.parseInt(disea.toString())) {
//                  1.高血压 2糖尿病 3.高血压+糖尿病
                    case 1:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "高血压", 1, "疾病类型", 2, surveyCode);
                        break;
                    case 2:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "糖尿病", 2, "疾病类型", 2, surveyCode);
                        break;
                }*/
                surveyDimensionDetailDao.save(surveyDimensionDetail);
                SurveyFilter surveyFilter = new SurveyFilter(getCode(), surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
//        List<String> codes = getCount(surveyTarget.toString());
        JSONObject countJson = new JSONObject();
        countJson.put("sex", sexList);
        countJson.put("disease", diseaList);
        countJson.put("healthCondition", healthList);
        countJson.put("service", servList);
        List<String> codes = getCountByDoctor(countJson.toString(),doctor);
        int amount = codes.size();
        for (String code : codes) {
//            String code = patient.get("patient").toString();
            SurveyUser user = new SurveyUser(surveyCode, code, 0, 1, new Date(), new Date());
            surveyUserDao.save(user);
        }
        //            发送居民模板 send=1发送
        if ("1".equals(send)) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            String str = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
//            JSONObject json = new JSONObject(str);
            JSONObject json = new JSONObject();
 /*           for (String code : codes) {
//            codes.stream().forEach(c -> {
//                Patient p = patientDao.findByCode(c);
                Patient p = patientDao.findByCode(code);
                String name = p.getName();
                String openId = p.getOpenid();
                json.put("keyword2", sdf.format(new Date()));
//                json.put("toUser", c);
                json.put("toUser", code);
                json.put("survey_id", surveyCode);
                json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                logger.error("patient =======>" + code);
                logger.error("name =======>" + name);
                logger.error("openId =======>" + openId);
                //判断是否有openId,有发送没有则查找家人发送
                if (StringUtils.isNotBlank(p.getOpenid())) {
                    // 添加到发送队列
                    logger.error("json =======>" + json);
                    PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
                } else {
                    JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(p.getOpenid());
                    Patient member = (Patient) j.get("member");
                    if (StringUtils.isNotBlank(member.getOpenid())) {
                        String first = (String) json.get("first");
                        json.remove("first");
                        try {
                            json.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), member.getName()) + first);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        logger.error("没有opIn  json =======>" + json);
                        PushMsgTask.getInstance().putWxMsg(accessToken, 11, member.getOpenid(), member.getName(), json);
                    }
                }
//            });
            }*/
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","scwj");
            String remark = templateConfig.getRemark();
            String keyword1 = templateConfig.getKeyword1();
            String wxTemplateCode = templateCode;
            new Thread() {
                public void run() {
                    for (String c : codes) {
                        Patient p = null;
                        String name = null;
                        String openId = null;
                        String first = null;
                        try {
                            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("toUser", c);
                            json.put("url","jkpg/html/start-survey.html?survey="+wxTemplateCode+"_"+doctor);
//                          String first = name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。";
                            first = templateConfig.getFirst();
                            first = first.replace("key1",(name==null?"":name));
                            json.put("first", first);
                            json.put("remark", remark);
                        } catch (JSONException e) {
                            continue;
                        }
                        //判断是否判定openId,有没有发则查找家人发送
                        if (StringUtils.isNotBlank(p.getOpenid())) {
                            // 添加到发送队列
                            logger.error("json =======>" + json);
//                            PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
                            pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);
                        }else {
                            //发送代理人
                            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
                            if (jsonArray != null && jsonArray.length() > 0) {
                                for (int i = 0; i < jsonArray.length(); i++) {
                                    JSONObject j = jsonArray.getJSONObject(i);
                                    Patient member = (Patient) j.get("member");
                                    if (StringUtils.isNotBlank(member.getOpenid())) {
                                        json.remove("toUser");
                                        json.put("toUser", member.getCode());
                                        json.put("url","jkpg/html/start-survey.html?survey="+wxTemplateCode+"_"+doctor);
                                        json.remove("first");
                                        try {
                                            json.put("keyword1", keyword1);
                                            json.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + first);
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                        pushMsgTask.sendWeixinMessage(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), p.getName(), json);
                                    }
                                }
                            }
                        }
                    }
                }
            }.start();
        }
//       =====================================================
//     获取标签数组
        SurveyLabelInfo surveyLabelInfo = new SurveyLabelInfo();
        surveyLabelInfo.setCode(getCode());
        surveyLabelInfo.setRelationCode(surveyCode);
        surveyLabelInfo.setUseType(useType);
        surveyLabelInfo.setLabel(Integer.parseInt(templateLabel));
        SurveyLabelInfo ss = surveyLabelInfoDao.save(surveyLabelInfo);
       /* JSONArray lables = jsonStr.getJSONArray("label");
//        标签保存到wlyy_survey_label_info
        for (Object label : lables) {
            SurveyLabelInfo surveyLabelInfo = new SurveyLabelInfo();
            surveyLabelInfo.setCode(getCode());
            surveyLabelInfo.setRelationCode(surveyCode);
            surveyLabelInfo.setUseType(useType);
            surveyLabelInfo.setLabel(Integer.parseInt(label.toString()));
            SurveyLabelInfo ss = surveyLabelInfoDao.save(surveyLabelInfo);
        }*/
//        获取问题数组
        JSONArray questions = jsonStr.getJSONArray("questions");
        for (Object question : questions) {
            JSONObject tempQestion = new JSONObject(question.toString());
//            不分题型都有的属性
            String questionnaireCode = tempQestion.get("qstCode").toString();
            String title = tempQestion.get("title").toString();
            String comment = tempQestion.get("comment").toString();
            int type = Integer.parseInt(tempQestion.get("type").toString());
            int isRequired = Integer.parseInt(tempQestion.get("isRequired").toString());
            int sort = Integer.parseInt(tempQestion.get("sort").toString());
            int del = 1;
            String qstNextQuestion = null;
//            前提一定要有nextQuestion字段传入,没有为""
            if (!StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                qstNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempQestion.get("nextQuestion"));
                qstNextQuestion = (qstNextQuestion == null ? "0" : qstNextQuestion);
            }
            switch (type) {
                case 0:
//                    单选
                    SurveyQuestionnaire surveyQuestionnaire = new SurveyQuestionnaire();
                    surveyQuestionnaire.setCode(questionnaireCode);
                    surveyQuestionnaire.setTitle(title);
                    surveyQuestionnaire.setQuestionComment(comment);
                    surveyQuestionnaire.setQuestionType(type);
                    surveyQuestionnaire.setSurveyCode(surveyCode);
                    surveyQuestionnaire.setIsRequired(isRequired);
                    surveyQuestionnaire.setDel(del);
                    surveyQuestionnaire.setSort(sort);
                    surveyQuestionnaire.setCreateTime(new Date());
                    surveyQuestionnaire.setUpdateTime(new Date());
                    //                   单选没有最大最小选项数及题目逻辑跳转
                    surveyQuestionnaire.setMinNum(null);
                    surveyQuestionnaire.setMaxNum(null);
                    surveyQuestionnaire.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaireDao.save(surveyQuestionnaire);
                    //                        =======================选项保存=========================
                    //                选择题
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options) {
//                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        String optionCode = tempOption.get("optCode").toString();
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                            optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
                            optionNextQuestion = (optionNextQuestion == null ? "0" : optionNextQuestion);
                        }
//                        自主创建,插入表
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions(optionCode, haveComment, questionnaireCode, optionComment,
                                surveyCode, optionNextQuestion, required, optionSort, optionDel);
                       /* surveyQuestionnaireOptions.setCode(optionCode);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
                        surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);*/
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                单选题保存到统计表
                        String statisticsCode = getCode();
                        String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                        String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                        SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                        surveyStatisticsDao.save(statistics);
                    }
                    break;
                case 1:
//            多选特有属性
                    Integer maxOptions = null;
                    Integer minOptions = null;
                    if (!StringUtils.isEmpty(tempQestion.get("minOptions").toString())) {
                        minOptions = Integer.parseInt(tempQestion.get("minOptions").toString());
                    }
                    if (!StringUtils.isEmpty(tempQestion.get("maxOptions").toString())) {
                        maxOptions = Integer.parseInt(tempQestion.get("maxOptions").toString());
                    }
                    SurveyQuestionnaire surveyQuestionnaire1 = new SurveyQuestionnaire();
                    surveyQuestionnaire1.setCode(questionnaireCode);
                    surveyQuestionnaire1.setTitle(title);
                    surveyQuestionnaire1.setQuestionComment(comment);
                    surveyQuestionnaire1.setQuestionType(type);
                    surveyQuestionnaire1.setSurveyCode(surveyCode);
                    surveyQuestionnaire1.setIsRequired(isRequired);
                    surveyQuestionnaire1.setMinNum(minOptions);
                    surveyQuestionnaire1.setMaxNum(maxOptions);
                    surveyQuestionnaire1.setSort(sort);
                    surveyQuestionnaire1.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire1.setDel(del);
                    surveyQuestionnaire1.setCreateTime(new Date());
                    surveyQuestionnaire1.setUpdateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire1);
//                        =======================选项保存=========================
                    //                选择题
                    JSONArray options1 = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options1) {
//                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        String optionCode = tempOption.get("optCode").toString();
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                            optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
                            optionNextQuestion = (optionNextQuestion == null ? "0" : optionNextQuestion);
                        }
//                        自主创建,插入表
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
                        surveyQuestionnaireOptions.setCode(optionCode);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
                        surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                多选题保存到统计表
                        String statisticsCode = getCode();
                        String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                        String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                        SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                        surveyStatisticsDao.save(statistics);
                    }
//                        ===============================================================
                    break;
                case 2:
//            问答特有属性
                    /*String nextQuestion = null;
                    if (StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
                        nextQuestion = tempQestion.get("nextQuestion").toString();
                    }else {
                        nextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode,tempQestion.get("nextQuestion"));
                    }*/
                    SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
                    surveyQuestionnaire2.setCode(questionnaireCode);
                    surveyQuestionnaire2.setTitle(title);
                    surveyQuestionnaire2.setQuestionComment(comment);
                    surveyQuestionnaire2.setQuestionType(type);
                    surveyQuestionnaire2.setSurveyCode(surveyCode);
                    surveyQuestionnaire2.setIsRequired(isRequired);
//                   单选没有最大最小选项数
                    surveyQuestionnaire2.setMinNum(null);
                    surveyQuestionnaire2.setMaxNum(null);
                    surveyQuestionnaire2.setSort(sort);
                    surveyQuestionnaire2.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire2.setDel(del);
                    surveyQuestionnaire2.setUpdateTime(new Date());
                    surveyQuestionnaire2.setCreateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire2);
                    //                问答题保存到统计表(只负责更改数量不负责创建)
                    String statisticsCode = getCode();
                    String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                    SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, null, 0, null, null, type, sort, null);
                    surveyStatisticsDao.save(statistics);
                    break;
            }
        }
//        保存到问卷
        Survey survey = new Survey();
        survey.setCode(surveyCode);
        survey.setTitle(surveyName);
        survey.setSurveyComment(surveyComment);
        survey.setCreater(doctor);
        survey.setTemplateCode(templateCode);
        survey.setStatus(status);
        survey.setAmount(amount);
        survey.setCreateTime(new Date());
        survey.setUpdateTime(new Date());
        surveyDao.save(survey);
        return surveyCode;
    }
}

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

@ -8,16 +8,13 @@ package com.yihu.wlyy.service.common.account;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.ServerLabelTree;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientRecordLogDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.util.DateUtil;
@ -31,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -53,6 +49,8 @@ public class PatientService extends TokenService {
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private PatientRecordLogDao patientRecordLogDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private DoctorPatientDao doctorPatientDao;
@ -1134,6 +1132,17 @@ public class PatientService extends TokenService {
     */
    @Transactional
    public String clearOpenidByOpenid (String openid)  throws Exception{
        List<Patient> patientList = patientDao.findPatientByOpenid(openid);
        for (Patient patient :patientList){
            PatientRecordLog patientRecordLog = new PatientRecordLog();
            patientRecordLog.setCzrq(new Date());
            patientRecordLog.setPatient(patient.getCode());
            patientRecordLog.setIdCard(patient.getIdcard());
            patientRecordLog.setOpenId(patient.getOpenid());
            patientRecordLog.setPatientName(patient.getName());
            patientRecordLog.setSsc(patient.getSsc());
            patientRecordLogDao.save(patientRecordLog);
        }
        patientDao.clearOpenidByOpenid(openid);
        return "";
    }

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

@ -0,0 +1,123 @@
package com.yihu.wlyy.service.specialist;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.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.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2018/5/31.
 */
@Service
@Transactional
public class SpecialistScreenResultService extends BaseService {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistScreenResultService.class);
    @Autowired
    private SignPatientLabelDao signPatientLabelDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${specialist.url}")
    private String specialistUrl;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private TeamDiseaseRelationDao teamDiseaseRelationDao;
    @Autowired
    private PatientDiseaseServerDao patientDiseaseServerDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SpecialDiseaseDao specialDiseaseDao;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    public JSONArray getScreenList(String doctor,int type,Integer page,Integer size) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("doctor", doctor);
        param.put("type", type);
        param.put("pageNo", page);
        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"))) {
            return  rs.getJSONArray("detailModelList");
        }
        return null;
    }
    public JSONObject getScreenCount(String doctor) throws Exception {
        JSONObject jsonObject = new JSONObject();
        Map<String, Object> param = new HashedMap();
        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"))) {
            jsonObject =  rs.getJSONObject("obj");
            return  jsonObject;
        }
        jsonObject.put("status",-1);
        jsonObject.put("message",rs.get("message"));
        return jsonObject;
    }
    public JSONObject getSpecialScreenResultDetail(String code) throws Exception {
        Map<String, Object> param = new HashedMap();
        JSONObject jsonObject = new JSONObject();
        param.put("code", code);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getScreenResultDetail", param);
        JSONObject rs = new JSONObject(response.getContent());
        if (rs.getInt("status")==200) {
            jsonObject = rs.getJSONObject("obj");
            return  jsonObject;
        }
        jsonObject.put("status",-1);
        jsonObject.put("message",rs.get("message"));
        return jsonObject;
    }
}

+ 143 - 42
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
@ -20,7 +21,10 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
@ -76,6 +80,10 @@ public class SpecialistService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list) {
        if (list != null && list.size() > 0) {
@ -389,18 +397,19 @@ public class SpecialistService extends BaseService {
    public Map<String, Object> findSpecialistTeamInfo(String doctor, Long teamCode) {
        String sql = "SELECT t.id, " +
                " t. NAME, " +
                " t. name, " +
                " d.photo," +
                " d.hospital," +
                " d.hospital_name AS hospitalName," +
                " d.code AS doctor," +
                " d.name AS doctorName ," +
                " d.dept," +
                " d.dept_name AS deptName" +
                " md.hospital," +
                " md.hospital_name AS hospitalName," +
                " md.code AS doctor," +
                " md.name AS doctorName ," +
                " md.dept," +
                " md.dept_name AS deptName" +
                " FROM " +
                " wlyy_admin_team t " +
                " JOIN wlyy_admin_team_member m ON t.id = m.team_id " +
                " JOIN wlyy_doctor d ON d. CODE = t.leader_code " +
                " JOIN wlyy_doctor md ON md. CODE = m.doctor_code " +
                " WHERE " +
                " m.doctor_code = '" + doctor + "' " +
                " AND t.available = '1' " +
@ -528,7 +537,7 @@ public class SpecialistService extends BaseService {
        return mes;
    }
    public String agreeSpecialistTeam(String state, String relationCode, String remark, Long mesId) throws Exception {
    public String agreeSpecialistTeam(String token, String state, String relationCode, String remark, Long mesId) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("state", state);
        param.put("relationCode", relationCode);
@ -537,59 +546,82 @@ public class SpecialistService extends BaseService {
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            //置空消息
            if (mesId != null) {
                Message m = messageDao.findOne(mesId);
                m.setOver("0");
                m.setRead(0);
                messageDao.save(m);
            }
            JSONObject josn =  rs.getJSONObject("obj");
            SignFamily sign =  signFamilyDao.findByPatient(josn.getString("patient"));
            //判断是否有家庭医生,有家庭医生则通知家庭医生
            if(sign!=null){
                Patient p = patientDao.findByCode(josn.getString("patient"));
                Doctor d = doctorDao.findByCode(josn.getString("doctor"));
                // 添加签约申请消息
                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent("您有一个居民开通共管服务!");
                message.setRead(1);//设置未读
                message.setReceiver(sign.getDoctor());//设置接受医生的code
                message.setSender(p.getCode());//设置发送的用户
                message.setSenderName(p.getName());
                message.setCode(getCode());
                message.setTitle("专科医生共管通知");
                message.setType(18);//家庭签约取消信息
                message.setReadonly(0);//是否只读消息
                message.setSex(p.getSex());
                message.setOver("1");//未处理
                message.setRelationCode(relationCode);
                message.setDel("1");
                message.setState(1);
                JSONObject dataJson = new JSONObject();
                dataJson.put("doctor",d.getCode());
                dataJson.put("doctorName",d.getName());
                dataJson.put("hospital",d.getHospital());
                dataJson.put("hospitalName",d.getHospitalName());
                dataJson.put("dept",d.getDept());
                dataJson.put("deptName",d.getDeptName());
                message.setReason(dataJson.toString());
            JSONObject josn = rs.getJSONObject("obj");
            Patient p = patientDao.findByCode(josn.getString("patient"));
            Doctor d = doctorDao.findByCode(josn.getString("doctor"));
                messageDao.save(message);
            //如果医生拒绝,置空疾病服务类型
            if ("0".equals(state)) {
                List<PatientDiseaseServer> servers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode, "1");
                for (PatientDiseaseServer server : servers) {
                    server.setDel("0");
                }
                patientDiseaseServerDao.save(servers);
                //推送给居民模板消息
                pushWeiTemp(token, "0", remark, p, d);
            } else {
                //医生同意,推送全科医生消息
                SignFamily sign = signFamilyDao.findByPatient(josn.getString("patient"));
                //判断是否有家庭医生,有家庭医生则通知家庭医生
                if (sign != null) {
                    // 添加签约申请消息
                    Message message = new Message();
                    message.setCzrq(new Date());
                    message.setCreateTime(new Date());
                    message.setContent("您有一个居民开通共管服务!");
                    message.setRead(1);//设置未读
                    message.setReceiver(sign.getDoctor());//设置接受医生的code
                    message.setSender(p.getCode());//设置发送的用户
                    message.setSenderName(p.getName());
                    message.setCode(getCode());
                    message.setTitle("专科医生共管通知");
                    message.setType(18);//家庭签约取消信息
                    message.setReadonly(0);//是否只读消息
                    message.setSex(p.getSex());
                    message.setOver("1");//未处理
                    message.setRelationCode(relationCode);
                    message.setDel("1");
                    message.setState(1);
                    JSONObject dataJson = new JSONObject();
                    dataJson.put("doctor", d.getCode());
                    dataJson.put("doctorName", d.getName());
                    dataJson.put("hospital", d.getHospital());
                    dataJson.put("hospitalName", d.getHospitalName());
                    dataJson.put("dept", d.getDept());
                    dataJson.put("deptName", d.getDeptName());
                    message.setReason(dataJson.toString());
                    messageDao.save(message);
                    //推送给居民模板消息
                    pushWeiTemp(token, "1", "", p, d);
                }
            }
            return "1";
        }
        return "0";
    }
    public JSONObject findPatientSigninfo(String code) throws Exception {
    public JSONObject findPatientSigninfo(String code,String messageCode) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("code", code);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientSigninfo", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            if (StringUtils.isNoneBlank(messageCode)){
                Message message = messageDao.findByCode(messageCode);
                message.setRead(0);
                messageDao.save(message);
            }
            JSONObject json = rs.getJSONObject("obj");
            List<PatientDiseaseServer> patientDiseaseServers =  patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(code,"1");
            json.put("diseaseServer",patientDiseaseServers);
@ -626,5 +658,74 @@ public class SpecialistService extends BaseService {
        return null;
    }
    public JSONObject findPatientSignSpecialistInfo(String patient,String doctor) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("patient", patient);
        param.put("doctor", doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientSignSpecialistInfo", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            JSONObject j =rs.getJSONObject("obj");
            String relationCode =  j.getString("relationCode");
            j.put("server",patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode,"1"));
            return j;
        }
        return null;
    }
    public void pushWeiTemp(String token, String state, String remark, Patient patient, Doctor doctor) {
        logger.info("pushWeiTemp:"+patient.getCode()+"__openid:"+patient.getOpenid());
        if (StringUtils.isNotBlank(patient.getOpenid())) {
            WechatTemplateConfig temp;
            JSONObject json = new JSONObject();
            if ("0".equals(state)) {
                //拒绝
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspref");
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
                json.put("remark", temp.getRemark().replace("key1", StringUtils.isBlank(remark)?"详情请联系您的专科医生":remark));
                json.put("first", temp.getFirst().replace("key1", patient.getName()));
            } else {
                //同意
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspagr");
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
                json.put("remark", temp.getRemark());
                json.put("first", temp.getFirst().replace("key1", patient.getName()));
            }
            logger.info("weiTempJOSN:"+json.toString());
            pushMsgTask.putWxMsg(token, 24, patient.getOpenid(), patient.getName(), json);
        }
    }
    public Long findMessagePatientCount(String doctor){
        String sql ="SELECT " +
                " COUNT(s.sender) AS total " +
                " FROM " +
                " ( " +
                "  SELECT DISTINCT " +
                "   m.sender " +
                "  FROM " +
                "   wlyy_message m " +
                "  WHERE " +
                "   m.type IN (16,17) " +
                "  AND m.receiver = '"+doctor+"' " +
                "  AND m.has_read = 1 " +
                "  AND m.over = 1 " +
                " ) s";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Long total = 0L;
        if(list!=null&&list.size()>0){
            Map<String,Object> map = list.get(0);
            total = (Long)map.get("total");
        }
        return total;
    }
}

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

@ -10,6 +10,7 @@ import com.yihu.wlyy.repository.doctor.*;
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.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
@ -86,6 +87,8 @@ public class ManagerQuestionnaireService extends BaseService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private SurveyScreenResultService surveyScreenResultService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -97,6 +100,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");
        int status = 1;
//        自主创建
        int useType = 1;
@ -238,7 +242,12 @@ public class ManagerQuestionnaireService extends BaseService {
        countJson.put("healthCondition", healthList);
        countJson.put("service", servList);
        List<String> codes = getCount(countJson.toString());
        int amount = codes.size();
        /*if (templateLabel.contains("5")){
            codes = surveyScreenResultService.getCountByDoctor(countJson.toString(),doctor);
        }else {
           codes = getCount(countJson.toString());
        };*/
       int amount = codes.size();
        for (String code : codes) {
//            String code = patient.get("patient").toString();
            SurveyUser user = new SurveyUser(surveyCode, code, 0, 1, new Date(), new Date());
@ -1759,7 +1768,7 @@ public class ManagerQuestionnaireService extends BaseService {
//            获取每一道题的信息
            JSONObject question = new JSONObject(questions.get(i).toString());
            String qstCode = question.get("qstCode").toString();
            int qstsort = Integer.parseInt(question.get("sort").toString());
            //int qstsort = Integer.parseInt(question.get("sort").toString());
            int type = Integer.parseInt(question.get("type").toString());
            if (type != 2) {
                if (question.has("options")) {
@ -1769,7 +1778,7 @@ public class ManagerQuestionnaireService extends BaseService {
                        JSONObject option = new JSONObject(options.get(j).toString());
                        String code = getCode();
                        String optionCode = option.get("optionCode").toString();
                        int optsort = Integer.parseInt(option.get("sort").toString());
                        //int optsort = Integer.parseInt(option.get("sort").toString());
                        String comment = null;
                        int haveComment = 0;
                        if (option.has("comment")) {

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

@ -1,12 +1,20 @@
package com.yihu.wlyy.service.third.guahao;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.survey.SurveyScreenResult;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SurveyScreenResultDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.httplog.LogService;
@ -20,6 +28,7 @@ import org.dom4j.Element;
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 java.text.SimpleDateFormat;
@ -30,7 +39,7 @@ import java.util.*;
 * 厦门市民健康网挂号服务
 */
@Service
public class GuahaoXMService implements IGuahaoService {
public class GuahaoXMService extends BaseService implements IGuahaoService {
    private int nextDays = 8;  //一周内预约号
    private String ORG_LIST = "GetOrgListNew";//获取医院列表
@ -55,6 +64,13 @@ public class GuahaoXMService implements IGuahaoService {
    JwSmjkService jwSmjkService;
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private SurveyScreenResultDao surveyScreenResultDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private LogService logService;
@ -62,12 +78,20 @@ public class GuahaoXMService implements IGuahaoService {
    @Autowired
    private ConsultService consultService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctorDao doctorDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    /**
     * 解析挂号后
     */
    private String CreateOrderAfter(String response, String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String sectionType, String startTime, String endTime, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
    private String CreateOrderAfter(String response, String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String sectionType, String startTime, String endTime, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode,String surveyCode) throws Exception {
        String code = "";
        if (response.startsWith("error") || response.startsWith("System-Error")) {
            throw new Exception(response);
@ -80,6 +104,13 @@ public class GuahaoXMService implements IGuahaoService {
            throw new Exception(response);
        }
        Patient patient1 = null;
        try {
            patient1 = patientDao.findByCode(patient);
        }catch (Exception e){
            e.printStackTrace();
            System.out.println("获取病人信息失败");
        }
        // 查询医生职称和头像
        GuahaoDoctor doctor = null;
        try{
@ -128,12 +159,48 @@ public class GuahaoXMService implements IGuahaoService {
        }
        // 保存预约记录
        patientReservationDao.save(reservation);
        PatientReservation patientReservation = patientReservationDao.save(reservation);
        if(StringUtils.isNotBlank(dcode)){
            Patient p = patientService.findByCode(patient);
            consultService.sendMucMessageBySingnType(dcode,dname,patient,"我已成功为您预约:" + startTime + "," + hospitalName + hosDeptName + doctorName + "医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='" + reservation.getId() + "'>点击查看详情</a>","1",p.getName());
        }
        if (StringUtils.isNoneBlank(surveyCode)){
            SurveyScreenResult surveyScreenResult = surveyScreenResultDao.getSurveyScreenResultByCode(surveyCode);
            surveyScreenResult.setIsOrder(1);
            surveyScreenResult.setReservationCode(patientReservation.getCode());
            String sql = "update wlyy_survey_screen_result ssr set ssr.is_order = "+surveyScreenResult.getIsOrder()+"," +
                    "reservation_code = '"+surveyScreenResult.getReservationCode()+"' where ssr.id = '"+surveyScreenResult.getId()+"'";
            jdbcTemplate.update(sql);
            //发送消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent("您有一个居民开通专科服务");
            message.setRead(1);//设置未读
            message.setReceiver(doctorId);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(patientName);
            message.setCode(getCode());
            message.setSenderPhoto(patient1.getPhoto());
            message.setTitle("专科医生共管通知");
            message.setType(17);//家庭签约取消信息
            message.setReadonly(1);//是否只读消息
            message.setSex(patient1.getSex());
            message.setOver("1");//未处理
            message.setRelationCode(patientReservation.getCode());
            message.setDel("1");
            message.setState(1);
            JSONObject object = new JSONObject();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            object.put("name",patient1.getName());
            object.put("carq",sdf.format(patientReservation.getCzrq()));
            object.put("title",surveyScreenResult.getTemplateTitle());
            object.put("screenResult",surveyScreenResult.getScreenResult());
            message.setReason(object.toString());
            messageDao.save(message);
        }
        return code;
    }
@ -653,7 +720,7 @@ public class GuahaoXMService implements IGuahaoService {
            verificationXml(response,"获取医生排班表失败!",ORDER_CREATE,content,method,msgBody,res);
            //保存http日志
            logService.saveHttpLog(true,ORDER_CREATE,content,method,null,msgBody,res,null,logService.archiveType);
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, null, null);
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, null, null,null);
        } else {
            throw new Exception("该排班信息错误或者不存在!");
        }
@ -1161,7 +1228,7 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 转诊预约挂号
     */
    public String CreateOrderByDoctor(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
    public String CreateOrderByDoctor(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode,String surveyCode) throws Exception {
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -1175,9 +1242,9 @@ public class GuahaoXMService implements IGuahaoService {
            String startTime = map.get("startTime");
            String endTime = map.get("endTime");
            String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName,patientPhone);
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
            /*String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName,patientPhone);*/
            String response = "e07cfa6a-e134-4329-bb99-9b7dbffea79e|516|熊永强";
            re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode,surveyCode);
        } else {
            throw new Exception("该排班信息错误或者不存在!");
        }
@ -1185,4 +1252,48 @@ public class GuahaoXMService implements IGuahaoService {
        return re;
    }
    /**
     * 获取转诊信息
     *
     * @param relationCode 关联code
     * @return
     */
    public com.alibaba.fastjson.JSONObject getPatientReservationInfo(String relationCode){
        PatientReservation patientReservation = patientReservationDao.findByCode(relationCode);
        List<SurveyScreenResult> surveyScreenResults = null;
        Patient patient = null;
        SignFamily signFamily = null;
        Doctor doctor = null;
        int age = 0;
        if (patientReservation != null){
            surveyScreenResults = surveyScreenResultDao.getByReservationCode(relationCode);
            patient = patientDao.findByCode(patientReservation.getPatient());
            age = DateUtil.getAgeByBirthday(patient.getBirthday());
            signFamily = signFamilyDao.findByPatient(patientReservation.getPatient());
            doctor = doctorDao.findByCode(signFamily.getDoctor());
        }
        com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.toJSON(patientReservation);
        object.put("surveyScreenResults",surveyScreenResults);
        object.put("patient",patient);
        object.put("age",age);
        object.put("signFamily",signFamily);
        object.put("doctor",doctor);
        return object;
    }
    public JSONObject updateRecode(String messageCode,String surveyCode){
        Message message = messageDao.findByCode(messageCode);
        message.setOver("0");
        messageDao.save(message);
        SurveyScreenResult surveyScreenResult = surveyScreenResultDao.getSurveyScreenResultByCode(surveyCode);
        surveyScreenResult.setIsOrder(2);
        surveyScreenResultDao.save(surveyScreenResult);
        JSONObject object = new JSONObject();
        object.put("message",message);
        object.put("surveyScreenResult",surveyScreenResult);
        return object;
    }
}

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

@ -2,8 +2,6 @@
package com.yihu.wlyy.service.third.guahao;
import com.yihu.wlyy.entity.patient.PatientReservation;
import java.util.List;
import java.util.Map;

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

@ -840,6 +840,16 @@ public class PushMsgTask {
                keyword3.setColor("#000000");
                keyword3.setValue(json.getString("keyword3"));
                m.put("keyword3", keyword3);
            }else if (type == 24) {//结果处理通知
                temp.setTemplate_id(template_deal_with);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
                WechatTemplateData keyword2 = new WechatTemplateData();
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }
            temp.setData(m);

+ 47 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/qrcode/QrCodeController.java

@ -7,6 +7,7 @@ import com.yihu.wlyy.service.common.QrcodeService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -355,6 +356,52 @@ public class QrCodeController extends WeixinBaseController {
        }
    }
    /**
     * 根据场景值获取公众号永久二维码
     *
     * @param scene 场景值
     * @return 返回服务器二维码地址
     * @throws Exception
     */
    @RequestMapping(value = "/getQrcode_Img", method =  {RequestMethod.GET,RequestMethod.POST})
    @ApiOperation(value = "获取公众号二维码接口")
    public void getQrcodeImg(@ApiParam(name = "scene", defaultValue = "") @RequestParam(value = "scene", required = true) String scene,
                             HttpServletResponse response) throws Exception {
        try {
            // 二维码内容
            String content = "jkzl_" +scene;
            // 二维码图片文件名
            String fileName = "jkzl_"+scene;
            String path = QrCodeController.class.getResource("/").getPath().replace("/WEB-INF/classes/", "")
                    + File.separator + "qrcode";
            // 通过微信接口生成医生二维码
            qrcodeService.makeQrcodeFromWeiXin(content, fileName.replaceAll("\r\n", ""), path, getAccessToken());
            String pathFile = request.getSession().getServletContext().getRealPath("/")
                    + File.separator + "qrcode" + File.separator + fileName.replaceAll("\r\n", "")+".png";
            InputStream inputStream = new FileInputStream(pathFile);
            response.setCharacterEncoding("utf-8");
            response.setContentType("multipart/form-data");
            response.setHeader("Content-Disposition", "attachment;fileName=" + fileName.replaceAll("\r\n", "")+".png");
            OutputStream outputStream = response.getOutputStream();
            byte[] b = new byte[2048];
            int length = 0;
            while ((length = inputStream.read(b)) > 0) {
                outputStream.write(b, 0, length);
            }
            outputStream.flush();
            outputStream.close();
            inputStream.close();
        } catch (Exception e) {
            error(e);
        }
    }
    /**
     * 下载所有医生的二维码图片
     *

+ 33 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -318,9 +318,39 @@ public class DataHandingService {
                    deviceSqlList.add("UPDATE device.wlyy_devices SET binding_count='"+bindingCount +"' where device_code='"+String.valueOf(deviceMap.get("device_code"))+"'");
                }
            }
            String deviceStr[] = new String[deviceSqlList.size()];
            deviceStr = deviceSqlList.toArray(deviceStr);
            jdbcTemplate.batchUpdate(deviceStr);
            if (deviceSqlList.size()>0){
                String deviceStr[] = new String[deviceSqlList.size()];
                deviceStr = deviceSqlList.toArray(deviceStr);
                jdbcTemplate.batchUpdate(deviceStr);
            }
            //更新grant_org_code字段
            List<String> deviceNoCodeSqlList = new ArrayList<>();
            String orgCodeSql = "SELECT * FROM device.wlyy_devices WHERE grant_org_code IS NULL OR grant_org_code =''";
            List<DeviceDetail> noOrgList = jdbcTemplate.query(orgCodeSql,new BeanPropertyRowMapper<>(DeviceDetail.class));
            if (noOrgList!=null && noOrgList.size()>0){
                for (DeviceDetail deviceDetail:noOrgList){
                    String orgCode = "";
                    if (deviceDetail.getOrgName().contains("嵩屿")){
                        orgCode = "3502050100";
                    }
                    if (deviceDetail.getOrgName().contains("石塘")){
                        orgCode = "3502050200";
                    }
                    if (deviceDetail.getOrgName().contains("东孚")){
                        orgCode = "3502050300";
                    }
                    if (deviceDetail.getOrgName().contains("新阳")){
                        orgCode = "3502050400";
                    }
                    deviceNoCodeSqlList.add("UPDATE device.wlyy_devices SET grant_org_code='"+orgCode+"' where id='"+deviceDetail.getId()+"'");
                }
                if (deviceNoCodeSqlList.size()>0){
                    String deviceNoCodeStr[] = new String[deviceNoCodeSqlList.size()];
                    deviceNoCodeStr = deviceNoCodeSqlList.toArray(deviceNoCodeStr);
                    jdbcTemplate.batchUpdate(deviceNoCodeStr);
                }
            }
        }catch (Exception e){
            flag = false;
            e.printStackTrace();

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

@ -300,9 +300,9 @@ public class DataHandlingController extends BaseController {
    public String updateDevice(){
        try {
            boolean flag = dataHandingService.updateDeviceDefalut();
            if (flag){
            /*if (flag){
                dataHandingService.updateDevice();
            }
            }*/
            return write(200,"清洗数据成功!");
        }catch (Exception e){
            e.printStackTrace();

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -150,6 +150,9 @@ public class DoctorDeviceController extends BaseController {
			if (StringUtils.isNotEmpty(agreementPhoto)){
				device.setAgreementPhoto(commonUtil.copyTempImage(agreementPhoto));
			}
			/*if ("1".equals(device.getCategoryCode())){
				device.setUserType("-1");
			}*/
			//首绑和设备类型判断  判断是否可以增加积分
			Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
			boolean flag = (Boolean)checkMap.get("flag");

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.doctor.message;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.consult.ConsultTeam;
@ -503,4 +504,85 @@ public class DoctorMessageController extends BaseController {
            return error( -1, "操作失败!");
        }
    }
    /**
     * 待处理
     *
     * @return
     */
    @RequestMapping(value = "unTreated",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("专科医生待处理消息")
    public String selectUntreated() {
        try {
            JSONObject json = messageService.selectUntreated(getUID());
            return write(200, "获取消息总数成功!", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**
     * 居民签约申请消息列表
     *
     * @param page 页码
     * @param pageSize 每页大小
     * @return
     */
    @RequestMapping(value = "getFimalySign",method = RequestMethod.GET)
    @ApiOperation("居民签约申请消息列表")
    @ResponseBody
    public String getFimalySign(@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";
        }
        try {
            return write(200,"查询成功!","data",messageService.getFamilySign(getUID(),Integer.valueOf(page),Integer.valueOf(pageSize)));
        }catch (Exception e){
            error(e);
            return error( -1, "查询失败!");
        }
    }
    /**
     *
     * @param message
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "getSpecialist",method = RequestMethod.GET)
    @ApiOperation("专科医生待处理列表")
    @ResponseBody
    public String getSpecialist(@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.setType(object.getInteger("type"));
        message1.setOver(object.getString("over"));
        message1.setRead(object.getInteger("read"));
        message1.setReceiver(getUID());
        try {
            return write(200,"查询成功!","data",messageService.getSpecialistUnTreated(message1,Integer.valueOf(page),Integer.valueOf(pageSize)));
        }catch (Exception e){
            error(e);
            return error( -1, "查询失败!");
        }
    }
}

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

@ -575,6 +575,7 @@ public class PatientInfoController extends BaseController {
    @ResponseBody
    @ApiOperation("查询医生的签约居民")
    public String getPatientSignByDoctor(@ApiParam(value = "关键搜索词", name = "keyWord") @RequestParam(value = "keyWord",required = false,defaultValue = "")String keyWord,
                                         @ApiParam(value = "医生团队code", name = "teamCode") @RequestParam(value = "teamCode")long teamCode,
                                         @ApiParam(name="pageNo",value="第几页",defaultValue = "1") @RequestParam(value="pageNo",required = true) String pageNo,
                                         @ApiParam(name="pageSize",value="",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize){
        if (StringUtils.isBlank(pageSize)) {
@ -584,7 +585,7 @@ public class PatientInfoController extends BaseController {
            pageNo = "1";
        }
        try {
            return  write(200,"查找成功!","data",patientInfoService.getPatientSignByDoctor(Integer.parseInt(pageNo),Integer.parseInt(pageSize),keyWord,getUID()));
            return  write(200,"查找成功!","data",patientInfoService.getPatientSignByDoctor(Integer.parseInt(pageNo),Integer.parseInt(pageSize),keyWord,getUID(),teamCode));
        } catch (Exception e) {
            error(e);
            return error( -1, "查询失败!");

+ 48 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -4,16 +4,18 @@ import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
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 Trick on 2018/5/31.
@ -21,7 +23,7 @@ import java.util.Map;
@RestController
@RequestMapping(value = "/doctor/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-专病管理")
public class SpecialistController extends BaseController {
public class SpecialistController extends WeixinBaseController {
    @Autowired
    private SpecialistService specialistService;
@ -221,7 +223,7 @@ public class SpecialistController extends BaseController {
                                      @ApiParam(name = "remark", value = "审核失败原因") @RequestParam(required = false) String remark,
                                      @ApiParam(name = "mesId", value = "消息Id") @RequestParam(required = false) Long mesId) throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(state, relationCode, remark, mesId));
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
@ -231,9 +233,12 @@ public class SpecialistController extends BaseController {
    @RequestMapping(value = "/findPatientSigninfo", method = RequestMethod.GET)
    @ApiOperation(value = "医生审核")
    @ObserverRequired
    public String findPatientSigninfo(@ApiParam(name = "code", value = "专科医生签约code") @RequestParam(required = true) String code) {
    public String findPatientSigninfo(@ApiParam(name = "code", value = "专科医生签约code")
                                      @RequestParam(required = true) String code,
                                      @ApiParam(name = "messageCode", value = "消息code")
                                      @RequestParam(required = false) String messageCode) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientSigninfo(code));
            return write(200, "获取成功", "data", specialistService.findPatientSigninfo(code,messageCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
@ -262,4 +267,39 @@ public class SpecialistController extends BaseController {
        }
    }
    }
    @RequestMapping(value = "/findPatientSignSpecialistInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民与当前专科医生有效签约信息")
    public String findPatientSignSpecialistInfo(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient,
                                                @ApiParam(name = "doctor", value = "专科医生code") @RequestParam(required = true)String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientSignSpecialistInfo(patient,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findMessagePatientCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取等待专科医生处理消息人数")
    public String findMessagePatientCount(String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findMessagePatientCount(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findPatientDiseaseServerList", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民专病服务信息")
    public String findPatientDiseaseServerList(@ApiParam(name = "patient", value = "患者code") @RequestParam(required = true)String patient) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientDiseaseServerList(patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 62 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistScreenResultController.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.web.doctor.specialist;
import com.yihu.wlyy.service.specialist.SpecialistScreenResultService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by zhangdan on 2018/7/6.
 */
@RestController
@RequestMapping(value = "/doctor/specialist/screen", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "专科医生-疾病筛查部分")
public class SpecialistScreenResultController extends BaseController {
    @Autowired
    private SpecialistScreenResultService specialistScreenResultService;
    @RequestMapping(value = "/getList",method = RequestMethod.GET)
    @ApiOperation(value = "专科医生获取筛查记录列表")
    public String createSpecialistPatientRelation(@ApiParam(name = "doctor", value = "专科医生ID")@RequestParam(value = "doctor")String doctor,
                                                                         @ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                                                         @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
                                                                         @ApiParam(value = "1已跟踪 2已预约")@RequestParam(value = "type",required = false) int type){
        try {
            return write(200,"获取成功!","data",specialistScreenResultService.getScreenList(doctor,type,pageNo,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "getScreenCount",method = RequestMethod.POST)
    @ApiOperation(value = "专科医生首页--筛查已跟踪和已预约的数目")
    public String findSpecialistPatientRelation(@ApiParam(name = "doctor", value = "专科医生ID")@RequestParam(value = "doctor")String doctor){
        try {
            return write(200,"获取成功!","data",specialistScreenResultService.getScreenCount(doctor));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @RequestMapping(value = "getScreenResultDetail",method = RequestMethod.GET)
    @ApiOperation(value = "查看筛查结果记录详情")
    public String getScreenResultDetail(@ApiParam(value = "筛查结果唯一code")@RequestParam(value = "code") String code) {
        try {
            return write(200,"获取成功!","data",specialistScreenResultService.getSpecialScreenResultDetail(code));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
}

Fichier diff supprimé car celui-ci est trop grand
+ 62 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java


+ 5 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java

@ -568,24 +568,22 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
    @ResponseBody
    public String saveAnswer( @RequestParam String jsonData,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")int labelType,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")Integer labelType,
                              @ApiParam(value = "筛查入口(labelType=5时要填),0是第一次筛查 1是再次评估")@RequestParam(value = "isAgain")int isAgain,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source) {
        try {
            JSONObject json = new JSONObject(jsonData);
            //如果是评分筛查还要保存最后记录
            String screenResultcode = "";
            if (labelType==5){
                screenResultcode = surveyScreenResultService.saveScreenResult(patientCode,getUID(),isAgain,source,json);
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(patientCode,getUID(),isAgain,source,json));
            }else {
                managerQuestionnaireService.saveAnswer(patientCode, "",json);
                return write(200, "保存成功!");
            }
            managerQuestionnaireService.saveAnswer(patientCode, screenResultcode,json);
            return write(200, "保存成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");
        }
    }
}

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

@ -439,8 +439,8 @@ public class PatientDeviceController extends BaseController {
                message.setDel("1");
                messageDao.save(message);
                //全部解绑后去判断就更新设备表中是否绑定字段
                deviceDetailService.unBindUpdateIsBinding(pd.getDeviceSn());
                patientDeviceLogService.savePatientDeviceLog(pd,pd.getDeviceSn(),2,2);
                deviceDetailService.unBindUpdateIsBinding(pd.getDeviceSn());
                return success("设备已删除!");
            } else {
                return error(-1, "不存在该设备!");

+ 3 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java

@ -1,9 +1,7 @@
package com.yihu.wlyy.web.patient.specialist;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -14,16 +12,13 @@ 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 Trick on 2018/7/3.
 */
@RestController
@RequestMapping(value = "/patient/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-专病管理")
public class PatientSpecialistController extends BaseController{
public class PatientSpecialistController extends WeixinBaseController{
    @Autowired
    private SpecialistService specialistService;
@ -81,7 +76,7 @@ public class PatientSpecialistController extends BaseController{
    @ApiOperation(value = "医生审核")
    public String agreeSpecialistTeam(String state,String relationCode,String remark,Long mesId)throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam( state, relationCode, remark, mesId));
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");

+ 23 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -2,7 +2,9 @@ package com.yihu.wlyy.web.patient.survey;
import com.google.gson.JsonObject;
import com.yihu.es.entity.QuestionnaireWinningESDO;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.questionnaire.QuestionnaireUsers;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.questionnaire.QuestionnaireUsersDao;
import com.yihu.wlyy.rest.model.common.SimpleResult;
import com.yihu.wlyy.service.app.survey.SurveyScreenResultService;
@ -47,6 +49,8 @@ public class    PatientQuestionnaireController extends BaseController {
    private SurveyScreenResultService surveyScreenResultService;
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @RequestMapping(value = "getSurveySummary", method = RequestMethod.GET)
    @ApiOperation(value = "居民端获取问卷概述")
@ -102,8 +106,8 @@ public class    PatientQuestionnaireController extends BaseController {
    //----------------------------------疾病筛查-----------------------------------------//
    @RequestMapping(value = "getResultAndScreenList", method = RequestMethod.GET)
    @ApiOperation(value = "根据问卷标签类型获取筛查问卷列表和自己的筛查结果")
    @RequestMapping(value = "getScreenList", method = RequestMethod.GET)
    @ApiOperation(value = "根据问卷标签类型获取筛查问卷列表")
    @ResponseBody
    public String getResultAndScreenList(@ApiParam(value = "当前页")@RequestParam(value = "pageNo") int pageNo,
                                @ApiParam(value = "显示记录数")@RequestParam(value = "pageSize") int pageSize,
@ -116,6 +120,18 @@ public class    PatientQuestionnaireController extends BaseController {
        }
    }
    @RequestMapping(value = "getResultList", method = RequestMethod.GET)
    @ApiOperation(value = "获取自己的筛查结果")
    @ResponseBody
    public String getResultnList() {
        try {
            return write(200, "获取成功!", "data", surveyScreenResultService.patientGetResult(getRepUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "getResultByTemplateCode", method = RequestMethod.GET)
    @ApiOperation(value = "居民查看具体一个筛查模板自己的结果")
    @ResponseBody
@ -159,7 +175,7 @@ public class    PatientQuestionnaireController extends BaseController {
    @ApiOperation(value = "保存用户答案")
    @ResponseBody
    public String saveAnswer( @RequestParam String jsonData,
                              @ApiParam(value = "居民code")@RequestParam(value = "patientCode")String patientCode,
                              @ApiParam(value = "医生code")@RequestParam(value = "doctorCode",required = false)String doctorCode,
                              @ApiParam(value = "问卷标签")@RequestParam(value = "labelType")int labelType,
                              @ApiParam(value = "筛查入口(labelType=5时要填),0是第一次筛查 1是再次评估")@RequestParam(value = "isAgain")int isAgain,
                              @ApiParam(value = "来源(1医生发放 2居民自我评估)")@RequestParam(value = "source")int source) {
@ -167,12 +183,12 @@ public class    PatientQuestionnaireController extends BaseController {
            JSONObject json = new JSONObject(jsonData);
            //如果是评分筛查还要保存最后记录
            String screenResultcode = "";
            if (labelType==5){
                screenResultcode = surveyScreenResultService.saveScreenResult(patientCode,getUID(),isAgain,source,json);
                return  write(200, "保存成功!","data",surveyScreenResultService.saveScreenResultAndAnswer(getRepUID(),doctorCode,isAgain,source,json));
            }else {
                managerQuestionnaireService.saveAnswer(getRepUID(), "",json);
                return write(200, "保存成功!");
            }
            managerQuestionnaireService.saveAnswer(patientCode, screenResultcode,json);
            return write(200, "保存成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return write(-1, "保存失败!");

+ 3 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -2182,7 +2182,8 @@ public class EsStatisticsController extends BaseController {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int sort,
            @RequestParam(required = false) String lowLevel,
            @RequestParam(required = false) String year) {
            @RequestParam(required = false) String year,
            @RequestParam(required = false,defaultValue = "3") int sortType) {//1发放量 ,2绑定量,绑定率
        try {
            //如果年度是空,按当前时间计算是年度是属于那个年度
@ -2194,7 +2195,7 @@ public class EsStatisticsController extends BaseController {
                lowLevel = level - 1 + "";
            }
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year,deviceType));
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year,deviceType,sortType));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");

+ 48 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/specialist/ThirdSpecialistController.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.web.third.specialist;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2018/7/13.
 */
@RestController
@RequestMapping(value = "/third/specialist",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "专科医生信息")
public class ThirdSpecialistController extends BaseController{
    @Autowired
    private SpecialistService specialistService;
    @RequestMapping(value = "/findSpecialistTeamInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取专科医生所在团队信息")
    public String findSpecialistTeamInfo(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                         @ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode){
        try {
            return write(200, "获取成功", "data", specialistService.findSpecialistTeamInfo(doctor,teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findTeamDiseaseRelation", method = RequestMethod.GET)
    @ApiOperation(value = "获取团队专病服务信息")
    public String findTeamDiseaseRelation(@ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode) {
        try {
            return write(200, "获取成功", "data", specialistService.findTeamDiseaseRelation(teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 41 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdQrcodeController.java

@ -17,6 +17,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
/**
 * Created by Reece on 2017/8/30/030.
@ -54,4 +57,42 @@ public class ThirdQrcodeController extends WeixinBaseController {
        }
    }
    /**
     * 根据场景值获取公众号永久二维码
     *
     * @param scene 场景值
     * @return 返回服务器二维码地址
     * @throws Exception
     */
    @RequestMapping(value = "/getQrcodeImg", method = RequestMethod.POST)
    @ApiOperation(value = "获取公众号二维码接口")
    public void getQrcodeImg(@ApiParam(name = "scene", defaultValue = "") @RequestParam(value = "scene", required = true) String scene,
                             HttpServletResponse response) throws Exception {
        try {
            String content = "wechat_" + scene;
            String p = ThirdQrcodeController.class.getResource("/").getPath().replace("/WEB-INF/classes/", "");
            // 通过微信接口生成医生二维码
            String result = qrcodeService.getQrcodeFromWeiXin(content, content.replaceAll("\r\n", ""), p, getAccessToken());
            String path = request.getSession().getServletContext().getRealPath("/")
                    + File.separator + "qrcode" + File.separator + content.replaceAll("\r\n", "") + ".png";
            InputStream inputStream = new FileInputStream(path);
            response.setCharacterEncoding("utf-8");
            response.setContentType("multipart/form-data");
            response.setHeader("Content-Disposition", "attachment;fileName=" + content.replaceAll("\r\n", ""));
            OutputStream outputStream = response.getOutputStream();
            byte[] b = new byte[2048];
            int length = 0;
            while ((length = inputStream.read(b)) > 0) {
                outputStream.write(b, 0, length);
            }
            outputStream.flush();
            outputStream.close();
            inputStream.close();
        } catch (Exception e) {
            error(e);
        }
    }
}

+ 40 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java

@ -604,9 +604,11 @@ public class BookingController extends WeixinBaseController {
                                      @ApiParam(name = "dcode", value = "代预约医生编号", defaultValue = "test00000000005")
                                      @RequestParam(value = "dcode", required = true) String dcode,
                                      @ApiParam(name = "dname", value = "代预约医生名称", defaultValue = "组2全科医生")
                                      @RequestParam(value = "dname", required = true) String dname) {
                                      @RequestParam(value = "dname", required = true) String dname,
                                      @ApiParam(name="surveyCode",value = "筛选code",defaultValue = "a")
                                      @RequestParam(value = "surveyCode",required = true)String surveyCode) {
        try {
            String orderCode = guahaoXM.CreateOrderByDoctor(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
            String orderCode = guahaoXM.CreateOrderByDoctor(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode,surveyCode);
            //获取预约信息查询是否挂号成功
            PatientReservation obj = patientReservationService.findByCode(orderCode);
            if (obj != null) {
@ -833,6 +835,42 @@ public class BookingController extends WeixinBaseController {
    }
    /**
     * 获取病人转诊信息
     *
     * @param relationCode 关联预约记录code
     *
     * @return
     */
    @RequestMapping(value = "getPatientReservationInfo", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("获取病人转诊信息")
    public String getPatientReservationInfo(
            @ApiParam(name = "relationCode", value = "关联code")
            @RequestParam(value = "relationCode", required = true) String relationCode) {
        try {
            return write(200, "获取病人转诊信息", "data", guahaoXM.getPatientReservationInfo(relationCode));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "updateRecode", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("已转诊")
    public String updateRecode(
            @ApiParam(name = "messageCode", value = "消息code")
            @RequestParam(value = "messageCode", required = true) String messageCode,
            @ApiParam(name = "surveyCode", value = "筛选code")
            @RequestParam(value = "surveyCode", required = true) String surveyCode) {
        try {
            return write(200, "已转诊", "data", guahaoXM.updateRecode(messageCode,surveyCode));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 60 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -440,6 +440,28 @@ public class WeiXinEventProcess {
            // 构建回复消息XML
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }else if (StringUtils.isNotEmpty(eventKey) && (eventKey.startsWith("sp_disease_")||eventKey.startsWith("qrscene_sp_disease_"))){
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            // 二维码参数
            String[] keys = eventKey.replace("qrscene_","").replace("sp_disease_", "").split("_");
            //设置图文消息
            setSpDisease(articles,keys[0],keys[1],systemConf);
            // 构建回复消息XMLs
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }else if (StringUtils.isNotEmpty(eventKey) && (eventKey.startsWith("jkzl_")||eventKey.startsWith("qrscene_jkzl_"))){
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            // 二维码参数
//            String[] keys = eventKey.replace("qrscene_","").replace("sp_disease_", "").split("_");
            //设置图文消息
            setCurrency(articles,systemConf);
            // 构建回复消息XMLs
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }else {
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
@ -534,7 +556,7 @@ public class WeiXinEventProcess {
        picUrlConsult = picUrlConsult.replace("{server}", serverUrl);
        articleConsult.put("Url", urlConsult);
        articleConsult.put("Title", "把健康带回家,流动人口网上回访问卷赢电影票");
        articleConsult.put("Title", "新市民健康城市行,网上回访问卷赢电影票");
        articleConsult.put("Description", "数量有限,小伙伴们千万不要错过!");
        articleConsult.put("PicUrl", picUrlConsult);
@ -802,28 +824,39 @@ public class WeiXinEventProcess {
            // 构建回复消息XML
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }else if (StringUtils.isNotEmpty(eventKey) && eventKey.startsWith("sp_disease_")){
        }else if (StringUtils.isNotEmpty(eventKey) && (eventKey.startsWith("sp_disease_")||eventKey.startsWith("qrscene_sp_disease_"))){
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            // 二维码参数
            String[] keys = eventKey.replace("sp_disease_", "").split("_");
            String[] keys = eventKey.replace("qrscene_","").replace("sp_disease_", "").split("_");
            //设置图文消息
            setSpDisease(articles,keys[0],keys[1],systemConf);
            // 构建回复消息XMLs
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }else if (StringUtils.isNotEmpty(eventKey) && (eventKey.startsWith("jkzl_")||eventKey.startsWith("qrscene_jkzl_"))){
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            // 二维码参数
//            String[] keys = eventKey.replace("qrscene_","").replace("sp_disease_", "").split("_");
            //设置图文消息
            setCurrency(articles,systemConf);
            // 构建回复消息XMLs
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }
        return result;
    }
    public void setSpDisease(List<Map<String, String>> articles,String teamId,String doctor,Properties systemConf){
    public void setSpDisease(List<Map<String, String>> articles,String doctor,String teamId,Properties systemConf){
        String url = systemDictDao.findByDictName("SP_DISEASE").get(0).getCode();
        url = url.replace("{server}", wechat_base_url)
                 .replace("{appId}", appId)
                 .replace("{data}",doctor+"_"+teamId);
                 .replace("{data}",teamId+"_"+doctor);
        logger.info("setSpDisease:"+url);
        // 图文消息图片URL
@ -839,6 +872,28 @@ public class WeiXinEventProcess {
        articles.add(articleConsult);
    }
    public void setCurrency(List<Map<String, String>> articles,Properties systemConf){
        String url = systemDictDao.findByDictName("WX_CURRENCY_QR_PATH").get(0).getCode();
        String title = systemDictDao.findByDictName("WX_CURRENCY_QR_TITLE").get(0).getCode();
        String content = systemDictDao.findByDictName("WX_CURRENCY_QR_CONTENT").get(0).getCode();
        url = url.replace("{appId}", appId);
        logger.info("setCurrency:"+url);
        // 图文消息图片URL
        String picUrlConsult = systemConf.getProperty("currency_url");
        picUrlConsult = picUrlConsult.replace("{server}", serverUrl);
        Map<String, String> articleConsult = new HashMap<>();
        articleConsult.put("Url", url);
        articleConsult.put("Title", title);
        articleConsult.put("Description", content);
        articleConsult.put("PicUrl", picUrlConsult);
        logger.info("setCurrency:"+url+"_"+picUrlConsult+"_"+content+"_"+title);
        articles.add(articleConsult);
    }
    /**
     * 构建单个图文消息工具类
     *

+ 3 - 2
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -35,6 +35,7 @@ im:
#专病配置
specialist:
  #url: http://172.19.103.33:9797/svr-wlyy-specialist
  url: http://localhost:8070/
#物联网配置
iot:
@ -114,8 +115,8 @@ images:
sign:
  #check_upload: http://172.19.103.88:8011/wlyy_service
  check_upload: http://localhost:8070/
  check_upload: http://172.19.103.88:8011/wlyy_service
  #check_upload: http://localhost:8070/
express:

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

@ -38,6 +38,8 @@ patient_wifi_pic_url = {server}/images/wifi.png
patient_draw_pic_url = {server}/images/banner01.png
#专科医生签约图片地址
specialist_sign_url = {server}/images/SpBanner.png
#通用活动图片地址
currency_url = {server}/images/currency.png
#居民wifi链接
patient_wifi_url =http://freewifi.mobcb.com/Portal/Wx/login
#就诊记录

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

@ -3,6 +3,11 @@
   {
	  "name":"家庭医生",
	  "sub_button":[
	      {
            "type":"view",
           	"name":"健康评估",
           	"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkpg%2fhtml%2fjkpg.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          },
		  {
			"type":"view",
			"name":"签约管理",

+ 5 - 0
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_haicang.txt

@ -3,6 +3,11 @@
   {
	  "name":"家庭医生",
	  "sub_button":[
	      {
            "type":"view",
            "name":"健康评估",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkpg%2fhtml%2fjkpg.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          },
		  {
			"type":"view",
			"name":"签约管理",

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

@ -3,6 +3,11 @@
   {
	  "name":"家庭医生",
	  "sub_button":[
	      {
            "type":"view",
            "name":"健康评估",
            "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fjkpg%2fhtml%2fjkpg.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
          },
		  {
			"type":"view",
			"name":"签约管理",

BIN
patient-co/patient-co-wlyy/src/main/webapp/images/SpBanner.png


BIN
patient-co/patient-co-wlyy/src/main/webapp/images/banner01.png


BIN
patient-co/patient-co-wlyy/src/main/webapp/images/currency.png


BIN
patient-co/patient-co-wlyy/src/main/webapp/images/familycontract.png


BIN
patient-co/patient-co-wlyy/src/main/webapp/images/operatinginstructions.png


BIN
patient-co/patient-co-wlyy/src/main/webapp/images/patientPrenata.png


BIN
patient-co/patient-co-wlyy/src/main/webapp/images/visit.png


BIN
patient-co/patient-co-wlyy/src/main/webapp/images/xufangzhiyin_img.png