Browse Source

初始化

刘韬 6 years ago
parent
commit
7c5a1f7229

+ 6 - 3
PacsOnline_Wechat_Patient/src/main/java/com/zskk/controller/WeixinApiController.java

@@ -1,5 +1,6 @@
 package com.zskk.controller;
 
+import com.jfinal.weixin.sdk.api.AccessTokenApi;
 import com.jfinal.weixin.sdk.api.ApiConfigKit;
 import com.jfinal.weixin.sdk.api.ApiResult;
 import com.jfinal.weixin.sdk.api.CallbackIpApi;
@@ -23,8 +24,9 @@ public class WeixinApiController extends ApiController {
      */
     public void getToken() {
     	try {
-          String key = getPara("key");
-          String json = ApiConfigKit.getAccessTokenCache().get(key);
+//          String key = getPara("key");
+//          String json = ApiConfigKit.getAccessTokenCache().get(key);
+    		String json = AccessTokenApi.getAccessToken().getAccessToken();
           renderText(json);
 		} catch (Exception e) {
 			// TODO: handle exception
@@ -146,9 +148,10 @@ public class WeixinApiController extends ApiController {
 		Report reports = Report.dao.findById(reportId);
 		if (reportId == null || reports == null) {
 			renderNull();
+			return;
 		}
 		if (reports.getQrCode() == null || reports.getQrCode().isEmpty()) {		
-			String str = "{\"expire_seconds\": 2592000, \"action_name\": \"QR_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"ExamQR_" + reportId + "\"}}}";
+			String str = "{\"expire_seconds\": 2592000, \"action_name\": \"QR_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"ExamQR_" + reports.getExamId() + "\"}}}";
 	        ApiResult apiResult = QrcodeApi.create(str);
 	        apiResult.getStr("url");
 			reports.setQrCode(apiResult.getStr("url"));

+ 34 - 3
PacsOnline_Wechat_Patient/src/main/java/com/zskk/service/UserService.java

@@ -1,5 +1,6 @@
 package com.zskk.service;
 
+import java.io.IOException;
 import java.util.Date;
 import java.util.UUID;
 import com.jfinal.kit.PropKit;
@@ -7,8 +8,10 @@ import com.zskk.model.Exams;
 import com.zskk.model.User;
 import com.zskk.model.UserBind;
 
+import okhttp3.Call;
 import okhttp3.OkHttpClient;
 import okhttp3.Request;
+import okhttp3.Response;
 
 public class UserService {
 
@@ -16,9 +19,6 @@ public class UserService {
 
 	private static final String CAHR_CODE = "UTF-8";
 
-	// 业务逻辑请求
-	private static final String BASE_URL = PropKit.get("wx_base_url");
-
 	/**
 	 * 创建微信用户
 	 * 
@@ -177,4 +177,35 @@ public class UserService {
 	private String create_nonce_str() {
 		return UUID.randomUUID().toString();
 	}
+	
+	public static void main(String[] args) {
+		Request request = new Request.Builder()
+		        .url("http://wechat.pacsonline.cn/wx_patient/api/getQrcode?reportId=7e7a4cc7c93b4d2b")
+		        .get()//默认就是GET请求,可以不写
+		        .build();
+		Call call = OKHTTP_CLIENT.newCall(request);
+        //同步execute
+        //同步请求
+        //同步是耗时的
+        //同步execute需要开启子线程
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    Response response = call.execute();
+                    if (response.isSuccessful()) {
+                        String string = response.body().string();
+                        //调用者只需要实现provide方法就能拿到这个String了
+						System.out.println(string);
+                    }else {
+						System.out.println("");
+
+					}
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }).start();
+		
+	}
 }

+ 11 - 10
PacsOnline_Wechat_Patient/src/main/java/com/zskk/service/WeixinService.java

@@ -53,16 +53,17 @@ public class WeixinService {
 	}
 	
 	public static void main(String[] args) {
-			DruidPlugin druidPlugin = new DruidPlugin("jdbc:mysql://www.pacsonline.cn:3306/pacsonline?useSSL=false", "pacs",
-					"ZSKK@2017~!@#".trim());
-			druidPlugin.start();
-			ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
-
-			_MappingKit.mapping(arp);
-			arp.start();
-
-			Report report = Report.dao.findById("9c11936e4a8440d6");
-			System.out.println(report);
+//			DruidPlugin druidPlugin = new DruidPlugin("jdbc:mysql://www.pacsonline.cn:3306/pacsonline?useSSL=false", "pacs",
+//					"ZSKK@2017~!@#".trim());
+//			druidPlugin.start();
+//			ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
+//
+//			_MappingKit.mapping(arp);
+//			arp.start();
+//
+//			Report report = Report.dao.findById("9c11936e4a8440d6");
+//			System.out.println(report);
+		
 		
 	}
 }