Browse Source

初始化

刘韬 6 years ago
parent
commit
ee52db1fa3

+ 54 - 4
PacsOnline_Wechat_Patient/src/main/java/com/zskk/controller/WeixinMsgController.java

@@ -8,7 +8,6 @@ package com.zskk.controller;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import com.jfinal.weixin.sdk.api.CustomServiceApi;
 import com.jfinal.weixin.sdk.api.CustomServiceApi.Articles;
 import com.jfinal.weixin.sdk.jfinal.MsgControllerAdapter;
@@ -112,9 +111,60 @@ public class WeixinMsgController extends MsgControllerAdapter {
         if (InQrCodeEvent.EVENT_INQRCODE_SUBSCRIBE.equals(inQrCodeEvent.getEvent()))
         {
             log.debug("扫码未关注:" + inQrCodeEvent.getFromUserName());
-            OutTextMsg outMsg = new OutTextMsg(inQrCodeEvent);
-            outMsg.setContent("感谢您的关注,二维码内容:" + inQrCodeEvent.getEventKey());
-            render(outMsg);
+			User findUserWechats = User.dao.findFirst("select * from user where wx_openid = ?",inQrCodeEvent.getFromUserName());
+			String rid = inQrCodeEvent.getEventKey();
+			String[] arr = rid.split("_");
+			Exams exams = Exams.dao.findById(arr[2]);
+			if (exams == null) {
+				renderNull();
+			}
+			String toUrlString = String.format("http://wechat.client.pacsonline.cn/#/reportInfo/report?openid=%s&exam_id=%s&study_id=%s",inQrCodeEvent.getFromUserName(),exams.getId(),exams.getStudyId());
+			if (findUserWechats == null) {
+				UserService aService = ServiceFactory.getService(UserService.class);
+                User users = aService.createWxUser(inQrCodeEvent.getFromUserName());
+				UserBind userBind = UserBind.dao.findFirst("select * from user_bind where user_id=? and exam_id=?",users.getId(),exams.getId());
+				if (userBind == null) {
+					aService.bindUserReport(users.getId(), exams);
+				}
+
+				List<Articles> listgz = new ArrayList<Articles>();
+				Articles articles = new Articles();
+				articles.setTitle("欢迎关注中世康恺电子胶片平台,点此进入");
+				articles.setDescription("点击页面绑定手机号或检查信息,立即查看电子胶片");
+				articles.setUrl("http://wechat.client.pacsonline.cn/#/bind?openid=" + inQrCodeEvent.getFromUserName());
+				articles.setPicurl("http://work.pacsonline.cn/static/img/banner.e8ee043.png");
+				listgz.add(articles);
+				Articles articles1 = new Articles();
+				articles1.setTitle("点击查看本次影像和报告");
+				articles1.setDescription("欢迎使用中世康恺PacsOnline!\n点击进入查看详情,您可以分享给家属或医生,日后还可以在“我的报告”中查看本次影像和报告");
+				articles1.setUrl(toUrlString);
+				articles1.setPicurl("http://work.pacsonline.cn/static/img/banner.e8ee043.png");
+				listgz.add(articles1);
+				CustomServiceApi.sendNews(inQrCodeEvent.getFromUserName(), listgz);
+				renderNull();
+			}else {
+				UserService aService = ServiceFactory.getService(UserService.class);
+
+				findUserWechats.setSubscribeStatus(2);
+				findUserWechats.update();
+				
+				UserBind userBind = UserBind.dao.findFirst("select * from user_bind where user_id=? and exam_id=?",findUserWechats.getId(),exams.getId());
+				if (userBind == null) {
+					aService.bindUserReport(findUserWechats.getId(), exams);
+				}
+				CustomServiceApi.sendText(inQrCodeEvent.getFromUserName(), "欢迎关注中世康恺电子胶片平台!\n使用微信-“扫一扫”,扫描报告上的二维码,即可查看电子影像和报告");
+
+				List<Articles> list = new ArrayList<Articles>();
+				Articles articles1 = new Articles();
+				articles1.setTitle("点击查看本次影像和报告");
+				articles1.setDescription("欢迎使用中世康恺PacsOnline!\n点击进入查看详情,您可以分享给家属或医生,日后还可以在“我的报告”中查看本次影像和报告");
+				articles1.setUrl(toUrlString);
+				articles1.setPicurl("http://work.pacsonline.cn/static/img/banner.e8ee043.png");
+				list.add(articles1);
+				CustomServiceApi.sendNews(inQrCodeEvent.getFromUserName(), list);
+				renderNull();
+				
+			}		
         }
         if (InQrCodeEvent.EVENT_INQRCODE_SCAN.equals(inQrCodeEvent.getEvent()))
         {