123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- package service
-
- import (
- "crypto/hmac"
- "crypto/sha1"
- "encoding/base64"
- "encoding/json"
- "fmt"
- "gdyb/utils/csbhttp"
- "strconv"
- "time"
- )
-
-
- 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, timestamp_str string) (string, string) {
-
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
-
-
- inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
-
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "1101"
-
- if certificates == "3" {
- inputData["mdtrt_cert_type"] = "99"
- inputData["certno"] = certNo
- inputData["psn_cert_type"] = "99"
-
- } else {
- if id_card_type == 1 {
- inputData["mdtrt_cert_type"] = "03"
- inputData["card_sn"] = card_sn
- inputData["certno"] = certNo
- inputData["psn_cert_type"] = "01"
-
- } else {
- inputData["mdtrt_cert_type"] = "02"
- inputData["card_sn"] = ""
- inputData["certno"] = certNo
- inputData["psn_cert_type"] = "01"
- }
- }
-
- inputData["mdtrt_cert_no"] = certNo
- inputData["begntime"] = ""
- inputData["psn_name"] = ""
- input["data"] = inputData
- inputMessage["input"] = input
-
-
- bytesData, _ := json.Marshal(inputMessage)
-
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), ""
- }
- func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte []byte, json string) string {
- fmt.Println(url)
-
- csbHP := csbhttp.NewHttpParams("http://10.72.3.87:8086/CSB/1101")
-
- csbHP.SetMethod("post")
-
-
- csbHP.SetApi("hssServives")
- csbHP.SetVersion("1.0.0")
-
-
-
- csbHP.AddHeader("_api_timestamp", strconv.FormatInt(timestamp, 10))
- csbHP.AddHeader("_api_name", "hssServives")
- csbHP.AddHeader("_api_version", "1.0.0")
- csbHP.AddHeader("_api_access_key", ak)
- csbHP.AddHeader("Content-Type", "application/json;charset=UTF-8")
-
-
-
-
-
- csbHP.SetContentBody(json, nil)
-
- csbHP.SetAK(ak)
- csbHP.SetSK(sk)
-
- csbHP.Print()
-
-
- res, _, err := csbhttp.Invoke(*csbHP, strconv.FormatInt(timestamp, 10))
-
- if err != nil {
- fmt.Println(err)
- return ""
- }
- return res
- }
- func hmacsha1(keyStr, value string) string {
-
- key := []byte(keyStr)
- mac := hmac.New(sha1.New, key)
- mac.Write([]byte(value))
-
- res := base64.StdEncoding.EncodeToString(mac.Sum(nil))
-
- return res
- }
|