Sfoglia il codice sorgente

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 3 anni fa
parent
commit
6be4eae8e2

+ 3 - 1
controllers/js/jsyb_controller.go Vedi File

@@ -41,8 +41,10 @@ func (c *JSybController) PostOne() {
41 41
 	certificates := c.GetString("certificates")
42 42
 	url := c.GetString("url")
43 43
 	ak := c.GetString("ak")
44
+	key := c.GetString("key")
45
+
44 46
 	fmt.Println("url:" + url)
45
-	result, inputLog := service.Jsyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates, url, ak)
47
+	result, inputLog := service.Jsyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates, url, ak, key)
46 48
 	fmt.Println(result)
47 49
 	fmt.Println(inputLog)
48 50
 	var dat map[string]interface{}

+ 2 - 1
controllers/sg/his_api_controller.go Vedi File

@@ -2852,6 +2852,7 @@ func (c *HisApiController) GetRegisterInfo() {
2852 2852
 	medical_expenses, _ := c.GetFloat("medical_expenses")
2853 2853
 	social_type, _ := c.GetInt64("social_type")
2854 2854
 	med_type := c.GetString("social_type")
2855
+	key := c.GetString("key")
2855 2856
 
2856 2857
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2857 2858
 
@@ -2941,7 +2942,7 @@ func (c *HisApiController) GetRegisterInfo() {
2941 2942
 			var res ResultTwo
2942 2943
 			api := "http://192.168.3.111:9532/" + "jsyb/1101?cert_no=" + "" +
2943 2944
 				"&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
2944
-				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
2945
+				"&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber + "&key=" + key
2945 2946
 			fmt.Println(api)
2946 2947
 			resp, requestErr := http.Get(api)
2947 2948
 			if requestErr != nil {

+ 38 - 35
service/jsyb_service.go Vedi File

@@ -1,18 +1,21 @@
1 1
 package service
2 2
 
3 3
 import (
4
+	"bytes"
4 5
 	"crypto/hmac"
5 6
 	"crypto/sha1"
6 7
 	"encoding/base64"
7 8
 	"encoding/json"
8 9
 	"fmt"
9 10
 	"gdyb/utils/csbhttp"
11
+	"io/ioutil"
12
+	"net/http"
10 13
 	"strconv"
11 14
 	"time"
12 15
 )
13 16
 
14 17
 // 人员基本信息
15
-func Jsyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, request_url string, access_key string) (string, string) {
18
+func Jsyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, request_url string, access_key string, skey string) (string, string) {
16 19
 	//生成签名
17 20
 	nonce := GetRandomString(32)
18 21
 	timestamp := time.Now().Unix()
@@ -50,46 +53,46 @@ func Jsyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
50 53
 	input["data"] = inputData
51 54
 	inputMessage["input"] = input //交易输入
52 55
 
53
-	//var inputLog string
56
+	var inputLog string
54 57
 	bytesData, _ := json.Marshal(inputMessage)
55
-	//inputLog = string(bytesData)
58
+	inputLog = string(bytesData)
56 59
 	fmt.Println(string(bytesData))
57 60
 	if err != nil {
58 61
 		fmt.Println(err.Error())
59 62
 		return err.Error(), ""
60 63
 	}
61
-	//reader := bytes.NewReader(bytesData)
62
-	//
63
-	//request, err := http.NewRequest("POST", "http://10.72.3.87:8086/CSB/1101", reader)
64
-	//if err != nil {
65
-	//	fmt.Println(err.Error())
66
-	//	return err.Error(), ""
67
-	//}
68
-	//key := "_api_access_key=" + access_key + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
69
-	//
70
-	//request.Header.Set("Content-Type", "application/json;charset=UTF-8")
71
-	//request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
72
-	//request.Header.Set("_api_name", "hssServives")
73
-	//request.Header.Set("_api_version", "1.0.0")
74
-	//request.Header.Set("_api_access_key", access_key)
75
-	//request.Header.Set("_api_signature", hmacsha1(key, secret_key))
76
-	//
77
-	//client := http.Client{}
78
-	//resp, err := client.Do(request)
79
-	//if err != nil {
80
-	//	fmt.Println(err.Error())
81
-	//	return err.Error(), ""
82
-	//}
83
-	//respBytes, err := ioutil.ReadAll(resp.Body)
84
-	//if err != nil {
85
-	//	fmt.Println(err.Error())
86
-	//	return err.Error(), ""
87
-	//}
88
-	//fmt.Println(string(respBytes))
89
-	//str := string(respBytes)
90
-	//return str, inputLog
91
-	request_url = "http://10.72.3.87:8086/CSB/1101"
92
-	return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), ""
64
+	reader := bytes.NewReader(bytesData)
65
+
66
+	request, err := http.NewRequest("POST", "http://10.72.3.87:8086/CSB/1101", reader)
67
+	if err != nil {
68
+		fmt.Println(err.Error())
69
+		return err.Error(), ""
70
+	}
71
+	key := "_api_access_key=" + access_key + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
72
+
73
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
74
+	request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
75
+	request.Header.Set("_api_name", "hssServives")
76
+	request.Header.Set("_api_version", "1.0.0")
77
+	request.Header.Set("_api_access_key", access_key)
78
+	request.Header.Set("_api_signature", skey)
79
+
80
+	client := http.Client{}
81
+	resp, err := client.Do(request)
82
+	if err != nil {
83
+		fmt.Println(err.Error())
84
+		return err.Error(), ""
85
+	}
86
+	respBytes, err := ioutil.ReadAll(resp.Body)
87
+	if err != nil {
88
+		fmt.Println(err.Error())
89
+		return err.Error(), ""
90
+	}
91
+	fmt.Println(string(respBytes))
92
+	str := string(respBytes)
93
+	return str, inputLog
94
+	//request_url = "http://10.72.3.87:8086/CSB/1101"
95
+	//return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), ""
93 96
 }
94 97
 func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte []byte, json string) string {
95 98
 	fmt.Println(url)