|
@@ -15,10 +15,12 @@ import (
|
15
|
15
|
"github.com/shopspring/decimal"
|
16
|
16
|
"io"
|
17
|
17
|
"io/ioutil"
|
|
18
|
+ "log"
|
18
|
19
|
"math/rand"
|
19
|
20
|
"net/http"
|
20
|
21
|
"os"
|
21
|
22
|
"path/filepath"
|
|
23
|
+ "runtime"
|
22
|
24
|
"strconv"
|
23
|
25
|
"strings"
|
24
|
26
|
"syscall"
|
|
@@ -39,7 +41,7 @@ func HisManagerApiRegistRouters() {
|
39
|
41
|
beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
|
40
|
42
|
beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
|
41
|
43
|
beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
|
42
|
|
- beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
|
|
44
|
+
|
43
|
45
|
beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
|
44
|
46
|
beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
|
45
|
47
|
beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
|
|
@@ -51,14 +53,37 @@ func HisManagerApiRegistRouters() {
|
51
|
53
|
}
|
52
|
54
|
|
53
|
55
|
var (
|
54
|
|
- DllDef = syscall.MustLoadDLL("SSCard.dll")
|
55
|
|
- Iinit = DllDef.MustFindProc("Init")
|
|
56
|
+ DllDef = syscall.MustLoadDLL("SSCard.dll")
|
|
57
|
+ Iinit = DllDef.MustFindProc("Init")
|
56
|
58
|
readCard = DllDef.MustFindProc("ReadCardBas")
|
57
|
|
- str = make([]byte, 256)
|
58
|
|
- str1 = make([]byte, 256)
|
|
59
|
+ str = make([]byte, 256)
|
|
60
|
+ str1 = make([]byte, 256)
|
59
|
61
|
)
|
60
|
62
|
|
61
|
|
-func (c *HisApiController)TestGetBasBaseInfo() {
|
|
63
|
+func PrintErr() {
|
|
64
|
+ if err := recover(); err != nil {
|
|
65
|
+ file, ferr := os.Create("panic.log")
|
|
66
|
+ if ferr != nil {
|
|
67
|
+ fmt.Println("无法输出panic.log文件", ferr.Error())
|
|
68
|
+ return
|
|
69
|
+ }
|
|
70
|
+ defer file.Close()
|
|
71
|
+ g := log.New(file, "panic:", 0)
|
|
72
|
+ g.Printf("panic at %v", time.Now())
|
|
73
|
+ g.Printf("%v", err)
|
|
74
|
+ fmt.Printf("%v\r\n", err)
|
|
75
|
+ for i := 0; i < 10; i++ {
|
|
76
|
+ funcName, file, line, ok := runtime.Caller(i)
|
|
77
|
+ if ok {
|
|
78
|
+ fmt.Printf("[func:%v,file:%v,line:%v]\n", runtime.FuncForPC(funcName).Name(), file, line)
|
|
79
|
+ g.Printf("[func:%v,file:%v,line:%v]\n", runtime.FuncForPC(funcName).Name(), file, line)
|
|
80
|
+ }
|
|
81
|
+ }
|
|
82
|
+ }
|
|
83
|
+}
|
|
84
|
+
|
|
85
|
+func (c *HisApiController) TestGetBasBaseInfo() {
|
|
86
|
+ defer PrintErr()
|
62
|
87
|
ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
|
63
|
88
|
if ret != 0 {
|
64
|
89
|
fmt.Println("SSCard的报错原因:", err)
|
|
@@ -66,11 +91,10 @@ func (c *HisApiController)TestGetBasBaseInfo() {
|
66
|
91
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
67
|
92
|
return
|
68
|
93
|
}
|
69
|
|
-
|
|
94
|
+
|
70
|
95
|
result := int(ret)
|
71
|
96
|
fmt.Println("SSCard的运算结果为1:", result)
|
72
|
97
|
|
73
|
|
-
|
74
|
98
|
if readCard == nil {
|
75
|
99
|
fmt.Println("readcard is nil")
|
76
|
100
|
readCard = DllDef.MustFindProc("ReadCardBas")
|
|
@@ -81,7 +105,7 @@ func (c *HisApiController)TestGetBasBaseInfo() {
|
81
|
105
|
}
|
82
|
106
|
|
83
|
107
|
str = nil
|
84
|
|
- str1 = nil
|
|
108
|
+ str1 = nil
|
85
|
109
|
str = make([]byte, 256)
|
86
|
110
|
str1 = make([]byte, 256)
|
87
|
111
|
ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(256))
|
|
@@ -89,7 +113,7 @@ func (c *HisApiController)TestGetBasBaseInfo() {
|
89
|
113
|
fmt.Println(" str:", str)
|
90
|
114
|
fmt.Println(" str1:", str1)
|
91
|
115
|
str = nil
|
92
|
|
- str1 = nil
|
|
116
|
+ str1 = nil
|
93
|
117
|
str = make([]byte, 256)
|
94
|
118
|
str1 = make([]byte, 256)
|
95
|
119
|
runtime.GC()
|
|
@@ -99,10 +123,8 @@ func (c *HisApiController)TestGetBasBaseInfo() {
|
99
|
123
|
return
|
100
|
124
|
}
|
101
|
125
|
|
102
|
|
-
|
103
|
126
|
}
|
104
|
127
|
|
105
|
|
-
|
106
|
128
|
func (c *HisApiController) GetOrgInfo() {
|
107
|
129
|
miConfig, _ := service.FindMedicalInsuranceInfo(9919)
|
108
|
130
|
service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
|
|
@@ -194,256 +216,256 @@ func (c *HisApiController) GetHisPatientInfo() {
|
194
|
216
|
|
195
|
217
|
}
|
196
|
218
|
|
197
|
|
-func (c *HisApiController) Sscard() {
|
198
|
|
- id_card_type, _ := c.GetInt64("id_card_type")
|
199
|
|
- adminUser := c.GetAdminUserInfo()
|
200
|
|
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
201
|
|
-
|
202
|
|
- r := CardInit()
|
203
|
|
- fmt.Println(r)
|
204
|
|
-
|
205
|
|
- switch id_card_type {
|
206
|
|
- case 1:
|
207
|
|
- basStr, err := GetBasBaseInfo()
|
208
|
|
-
|
209
|
|
- if err != nil {
|
210
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
|
211
|
|
- return
|
212
|
|
-
|
213
|
|
- } else {
|
214
|
|
- fmt.Println(basStr)
|
215
|
|
-
|
216
|
|
- bas := strings.Split(basStr, "|")
|
217
|
|
-
|
218
|
|
- basNumber := bas[1]
|
219
|
|
-
|
220
|
|
-
|
221
|
|
- card_sn := bas[3]
|
222
|
|
-
|
223
|
|
- appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
|
224
|
|
-
|
225
|
|
- api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
|
226
|
|
- resp, requestErr := http.Get(api)
|
227
|
|
- if requestErr != nil {
|
228
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
229
|
|
- return
|
230
|
|
- }
|
231
|
|
- defer resp.Body.Close()
|
232
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
233
|
|
- if ioErr != nil {
|
234
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
235
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
236
|
|
- return
|
237
|
|
- }
|
238
|
|
- var respJSON map[string]interface{}
|
239
|
|
-
|
240
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
241
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
242
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
243
|
|
- return
|
244
|
|
- }
|
245
|
|
-
|
246
|
|
- userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
247
|
|
- userJSONBytes, _ := json.Marshal(userJSON)
|
248
|
|
- var res ResultTwo
|
249
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
250
|
|
- utils.ErrorLog("解析失败:%v", err)
|
251
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
252
|
|
- return
|
253
|
|
- }
|
254
|
|
- Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
255
|
|
- Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
256
|
|
- infoStr := string(Iinfos)
|
257
|
|
- idetinfoStr := string(Idetinfos)
|
258
|
|
-
|
259
|
|
- if res.Infcode == 0 {
|
260
|
|
- his := models.VMHisPatient{
|
261
|
|
- Status: 1,
|
262
|
|
- Ctime: time.Now().Unix(),
|
263
|
|
- Mtime: time.Now().Unix(),
|
264
|
|
- PsnNo: res.Output.Baseinfo.PsnNo,
|
265
|
|
- PsnCertType: res.Output.Baseinfo.PsnCertType,
|
266
|
|
- Certno: res.Output.Baseinfo.Certno,
|
267
|
|
- PsnName: res.Output.Baseinfo.PsnName,
|
268
|
|
- Gend: res.Output.Baseinfo.Gend,
|
269
|
|
- Naty: res.Output.Baseinfo.Naty,
|
270
|
|
- Brdy: res.Output.Baseinfo.Brdy,
|
271
|
|
- Age: res.Output.Baseinfo.Age,
|
272
|
|
- Iinfo: infoStr,
|
273
|
|
- Idetinfo: idetinfoStr,
|
274
|
|
- UserOrgId: adminUser.CurrentOrgId,
|
275
|
|
- IsReturn: 1,
|
276
|
|
- IdCardType: id_card_type,
|
277
|
|
- }
|
278
|
|
-
|
279
|
|
- patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
|
280
|
|
- if err == gorm.ErrRecordNotFound {
|
281
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
|
282
|
|
- return
|
283
|
|
-
|
284
|
|
- } else if err != nil {
|
285
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
286
|
|
- return
|
287
|
|
-
|
288
|
|
- } else {
|
289
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
290
|
|
- "patient": patient,
|
291
|
|
- "his": his,
|
292
|
|
- "number": basNumber,
|
293
|
|
- })
|
294
|
|
- }
|
295
|
|
- } else {
|
296
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
|
297
|
|
- return
|
298
|
|
- }
|
299
|
|
-
|
300
|
|
- }
|
301
|
|
-
|
302
|
|
- break
|
303
|
|
- case 2:
|
304
|
|
-
|
305
|
|
-
|
306
|
|
-
|
307
|
|
-
|
308
|
|
-
|
309
|
|
-
|
310
|
|
-
|
311
|
|
-
|
312
|
|
-
|
313
|
|
-
|
314
|
|
-
|
315
|
|
-
|
316
|
|
-
|
317
|
|
-
|
318
|
|
-
|
319
|
|
-
|
320
|
|
-
|
321
|
|
-
|
322
|
|
-
|
323
|
|
-
|
324
|
|
-
|
325
|
|
-
|
326
|
|
-
|
327
|
|
-
|
328
|
|
-
|
329
|
|
-
|
330
|
|
-
|
331
|
|
-
|
332
|
|
-
|
333
|
|
-
|
334
|
|
-
|
335
|
|
-
|
336
|
|
-
|
337
|
|
-
|
338
|
|
-
|
339
|
|
-
|
340
|
|
-
|
341
|
|
-
|
342
|
|
-
|
343
|
|
-
|
344
|
|
-
|
345
|
|
-
|
346
|
|
-
|
347
|
|
-
|
348
|
|
-
|
349
|
|
-
|
350
|
|
-
|
351
|
|
-
|
352
|
|
-
|
353
|
|
-
|
354
|
|
-
|
355
|
|
-
|
356
|
|
-
|
357
|
|
-
|
358
|
|
-
|
359
|
|
-
|
360
|
|
-
|
361
|
|
-
|
362
|
|
-
|
363
|
|
-
|
364
|
|
-
|
365
|
|
-
|
366
|
|
-
|
367
|
|
-
|
368
|
|
-
|
369
|
|
-
|
370
|
|
-
|
371
|
|
-
|
372
|
|
-
|
373
|
|
-
|
374
|
|
-
|
375
|
|
-
|
376
|
|
-
|
377
|
|
-
|
378
|
|
-
|
379
|
|
-
|
380
|
|
-
|
381
|
|
-
|
382
|
|
-
|
383
|
|
-
|
384
|
|
-
|
385
|
|
- break
|
386
|
|
- case 3:
|
387
|
|
-
|
388
|
|
- break
|
389
|
|
-
|
390
|
|
- }
|
391
|
|
-}
|
392
|
|
-
|
393
|
|
-func GetBasBaseInfo() (jsonStr string, err error) {
|
394
|
|
-
|
395
|
|
- handle, err := syscall.LoadLibrary("SSCard.dll")
|
396
|
|
- if err != nil {
|
397
|
|
- fmt.Printf("Error: %s\n", err)
|
398
|
|
- return "", err
|
399
|
|
- }
|
400
|
|
- defer syscall.FreeLibrary(handle)
|
401
|
|
- str := make([]byte, 256)
|
402
|
|
- str1 := make([]byte, 256)
|
403
|
|
- add, err := syscall.GetProcAddress(handle, "ReadCardBas")
|
404
|
|
- if err != nil {
|
405
|
|
- fmt.Printf("Error: %s\n", err)
|
406
|
|
- return "", err
|
407
|
|
- }
|
408
|
|
- ret, _, _ := syscall.Syscall(add, (uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
|
409
|
|
- if err != nil {
|
410
|
|
- fmt.Printf("Error: %s\n", err)
|
411
|
|
- }
|
412
|
|
- fmt.Println("> Add(4,5)的结果为:", ret)
|
413
|
|
-
|
414
|
|
-
|
415
|
|
-
|
416
|
|
-
|
417
|
|
-
|
418
|
|
-
|
419
|
|
-
|
420
|
|
-
|
421
|
|
-
|
422
|
|
-
|
423
|
|
-
|
424
|
|
-
|
425
|
|
-
|
426
|
|
-
|
427
|
|
-
|
428
|
|
-
|
429
|
|
-
|
430
|
|
-
|
431
|
|
-
|
432
|
|
-
|
433
|
|
-
|
434
|
|
-
|
435
|
|
-
|
436
|
|
-
|
437
|
|
-
|
438
|
|
-
|
439
|
|
-
|
440
|
|
-
|
441
|
|
-
|
442
|
|
-
|
443
|
|
-
|
444
|
|
- return "", nil
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
445
|
414
|
|
446
|
|
-}
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
447
|
469
|
|
448
|
470
|
|
449
|
471
|
|
|
@@ -2921,6 +2943,6 @@ func RemoveRepeatedCode(arr []string) (newArr []string) {
|
2921
|
2943
|
|
2922
|
2944
|
|
2923
|
2945
|
|
2924
|
|
-func StrPtr3(s string) uintptr {
|
2925
|
|
- return uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s)))
|
2926
|
|
-}
|
|
2946
|
+
|
|
2947
|
+
|
|
2948
|
+
|