csx 4 years ago
parent
commit
e55dbbb840
2 changed files with 21 additions and 5 deletions
  1. 18 3
      controllers/sg/his_api_controller.go
  2. 3 2
      service/sz_his_service.go

+ 18 - 3
controllers/sg/his_api_controller.go View File

@@ -21,6 +21,7 @@ import (
21 21
 	"os"
22 22
 	"path/filepath"
23 23
 	"runtime"
24
+	_ "runtime/cgo"
24 25
 	"strconv"
25 26
 	"strings"
26 27
 	"syscall"
@@ -50,12 +51,27 @@ func HisManagerApiRegistRouters() {
50 51
 	beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
51 52
 	beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
52 53
 
54
+	beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
55
+
53 56
 }
54 57
 
55
-var ()
58
+func (c *HisApiController) TestPay() {
59
+	runtime.GC()
60
+	DllDef := syscall.MustLoadDLL("SSSE32.dll")
61
+	readCard := DllDef.MustFindProc("ReadCardBas")
62
+	str := make([]byte, 256)
63
+	str1 := make([]byte, 256)
64
+	ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
65
+	runtime.GC()
66
+	if err2 != nil {
67
+		fmt.Println("SSCard的运算结果为:", ret2)
68
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
69
+		return
70
+	}
71
+
72
+}
56 73
 
57 74
 func (c *HisApiController) TestGetBasBaseInfo() {
58
-	runtime.GC()
59 75
 
60 76
 	DllDef := syscall.MustLoadDLL("SSCard.dll")
61 77
 	Iinit := DllDef.MustFindProc("Init")
@@ -86,7 +102,6 @@ func (c *HisApiController) TestGetBasBaseInfo() {
86 102
 	fmt.Println(" Add(4,5)的结果为:", ret2)
87 103
 	fmt.Println(" str:", str)
88 104
 	fmt.Println(" str1:", str1)
89
-	runtime.GC()
90 105
 	if err2 != nil {
91 106
 		fmt.Println("SSCard的运算结果为:", ret2)
92 107
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)

+ 3 - 2
service/sz_his_service.go View File

@@ -12,14 +12,14 @@ import (
12 12
 	_ "unsafe"
13 13
 )
14 14
 
15
-func SzybMZ002(doctor string, doctor_code string, fixmedins_code string, dept_code string) string {
15
+func SzybMZ002(doctor string, doctor_code string, fixmedins_code string, dept_code string, account string) string {
16 16
 	// 生成输入报文
17 17
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code)
18 18
 	inputData := make(map[string]interface{})
19 19
 	inputMessage["transType"] = "MZ002" // 交易编码
20 20
 
21 21
 	inputData["akc190"] = inputMessage["serialNumber"]
22
-	inputData["aaz500"] = "%GAAFSAKSXSUKKWDKHDAD?;07734724145330238292?"
22
+	inputData["aaz500"] = account
23 23
 	inputData["bzz269"] = "000000"
24 24
 	inputData["aka130"] = "11"
25 25
 	inputData["akf001"] = dept_code
@@ -58,6 +58,7 @@ func SzybMZ002(doctor string, doctor_code string, fixmedins_code string, dept_co
58 58
 	str := string(respBytes)
59 59
 	return str
60 60
 }
61
+
61 62
 func SzybFY001(doctor string, doctor_code string, fixmedins_code string, dept_code string, datas []*models.CustomDetail) string {
62 63
 	// 生成输入报文
63 64
 	inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code)