Browse Source

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

csx 4 years ago
parent
commit
5b909bbca2
1 changed files with 222 additions and 222 deletions
  1. 222 222
      controllers/sg/his_api_controller.go

+ 222 - 222
controllers/sg/his_api_controller.go View File

@@ -244,219 +244,219 @@ func (c *HisApiController) GetHisPatientInfo() {
244 244
 	}
245 245
 }
246 246
 
247
-func (c *HisApiController) Sscard() {
248
-	//id_card_type, _ := c.GetInt64("id_card_type")
249
-	//adminUser := c.GetAdminUserInfo()
250
-	//miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
251
-	id_card_type := 1
252
-	r := CardInit()
253
-	fmt.Println(r)
254
-	//if r == 0 {
255
-	switch id_card_type {
256
-	case 1:
257
-		defer GetBasBaseInfo()
258
-
259
-		//if err != nil {
260
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
261
-		//	return
262
-		//
263
-		//} else {
264
-		//	fmt.Println(basStr)
265
-		//
266
-		//	bas := strings.Split(basStr, "|")
267
-		//
268
-		//	basNumber := bas[1]
269
-		//
270
-		//	//basNumber := bas[2]
271
-		//	card_sn := bas[3]
272
-		//
273
-		//	appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
274
-		//
275
-		//	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
276
-		//	resp, requestErr := http.Get(api)
277
-		//	if requestErr != nil {
278
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
279
-		//		return
280
-		//	}
281
-		//	defer resp.Body.Close()
282
-		//	body, ioErr := ioutil.ReadAll(resp.Body)
283
-		//	if ioErr != nil {
284
-		//		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
285
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
286
-		//		return
287
-		//	}
288
-		//	var respJSON map[string]interface{}
289
-		//
290
-		//	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
291
-		//		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
292
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
293
-		//		return
294
-		//	}
295
-		//
296
-		//	userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
297
-		//	userJSONBytes, _ := json.Marshal(userJSON)
298
-		//	var res ResultTwo
299
-		//	if err := json.Unmarshal(userJSONBytes, &res); err != nil {
300
-		//		utils.ErrorLog("解析失败:%v", err)
301
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
302
-		//		return
303
-		//	}
304
-		//	Iinfos, _ := json.Marshal(res.Output.Iinfo)
305
-		//	Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
306
-		//	infoStr := string(Iinfos)
307
-		//	idetinfoStr := string(Idetinfos)
308
-		//
309
-		//	if res.Infcode == 0 {
310
-		//		his := models.VMHisPatient{
311
-		//			Status:      1,
312
-		//			Ctime:       time.Now().Unix(),
313
-		//			Mtime:       time.Now().Unix(),
314
-		//			PsnNo:       res.Output.Baseinfo.PsnNo,
315
-		//			PsnCertType: res.Output.Baseinfo.PsnCertType,
316
-		//			Certno:      res.Output.Baseinfo.Certno,
317
-		//			PsnName:     res.Output.Baseinfo.PsnName,
318
-		//			Gend:        res.Output.Baseinfo.Gend,
319
-		//			Naty:        res.Output.Baseinfo.Naty,
320
-		//			Brdy:        res.Output.Baseinfo.Brdy,
321
-		//			Age:         res.Output.Baseinfo.Age,
322
-		//			Iinfo:       infoStr,
323
-		//			Idetinfo:    idetinfoStr,
324
-		//			UserOrgId:   adminUser.CurrentOrgId,
325
-		//			IsReturn:    1,
326
-		//			IdCardType:  id_card_type,
327
-		//		}
328
-		//
329
-		//		patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
330
-		//		if err == gorm.ErrRecordNotFound {
331
-		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
332
-		//			return
333
-		//
334
-		//		} else if err != nil {
335
-		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
336
-		//			return
337
-		//
338
-		//		} else {
339
-		//			c.ServeSuccessJSON(map[string]interface{}{
340
-		//				"patient": patient,
341
-		//				"his":     his,
342
-		//				"number":  basNumber,
343
-		//			})
344
-		//		}
345
-		//	} else {
346
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
347
-		//		return
348
-		//	}
349
-		//
350
-		//}
351
-
352
-		break
353
-	case 2:
354
-		////SFZStr, err := GetSFZBaseInfo()
355
-		//if err != nil {
356
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
357
-		//	return
358
-		//
359
-		//} else {
360
-		//
361
-		//	id_card_str := strings.Split(SFZStr, "^")
362
-		//	id_card_number := id_card_str[0]
363
-		//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
364
-		//
365
-		//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&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)
366
-		//resp, requestErr := http.Get(api)
367
-		//if requestErr != nil {
368
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
369
-		//	return
370
-		//}
371
-		//defer resp.Body.Close()
372
-		//body, ioErr := ioutil.ReadAll(resp.Body)
373
-		//if ioErr != nil {
374
-		//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
375
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
376
-		//	return
377
-		//}
378
-		//var respJSON map[string]interface{}
379
-		//
380
-		//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
381
-		//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
382
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
383
-		//	return
384
-		//}
385
-		//
386
-		//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
387
-		//userJSONBytes, _ := json.Marshal(userJSON)
388
-		//var res ResultTwo
389
-		//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
390
-		//	utils.ErrorLog("解析失败:%v", err)
391
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
392
-		//	return
393
-		//}
394
-		//Iinfos, _ := json.Marshal(res.Output.Iinfo)
395
-		//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
396
-		//infoStr := string(Iinfos)
397
-		//idetinfoStr := string(Idetinfos)
398
-		//
399
-		//if res.Infcode == 0 {
400
-		//	his := models.VMHisPatient{
401
-		//		Status:      1,
402
-		//		Ctime:       time.Now().Unix(),
403
-		//		Mtime:       time.Now().Unix(),
404
-		//		PsnNo:       res.Output.Baseinfo.PsnNo,
405
-		//		PsnCertType: res.Output.Baseinfo.PsnCertType,
406
-		//		Certno:      res.Output.Baseinfo.Certno,
407
-		//		PsnName:     res.Output.Baseinfo.PsnName,
408
-		//		Gend:        res.Output.Baseinfo.Gend,
409
-		//		Naty:        res.Output.Baseinfo.Naty,
410
-		//		Brdy:        res.Output.Baseinfo.Brdy,
411
-		//		Age:         res.Output.Baseinfo.Age,
412
-		//		Iinfo:       infoStr,
413
-		//		Idetinfo:    idetinfoStr,
414
-		//		UserOrgId:   adminUser.CurrentOrgId,
415
-		//		IsReturn:    1,
416
-		//		IdCardType:  id_card_type,
417
-		//	}
418
-
419
-		//	patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
420
-		//	if err == gorm.ErrRecordNotFound {
421
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
422
-		//		return
423
-		//
424
-		//	} else if err != nil {
425
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
426
-		//		return
427
-		//
428
-		//	} else {
429
-		//		c.ServeSuccessJSON(map[string]interface{}{
430
-		//			"patient": patient,
431
-		//			"number":  id_card_number,
432
-		//		})
433
-		//	}
434
-		//}
435
-		break
436
-	case 3:
437
-
438
-		break
439
-
440
-	}
441
-}
442
-
443
-func GetBasBaseInfo() (jsonStr string, err error) {
444
-
445
-	handle := syscall.NewLazyDLL("SSCard.dll")
446
-	add := handle.NewProc("ReadCardBas")
447
-	str := make([]byte, 1024)
448
-	str1 := make([]byte, 1024)
449
-	ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
450
-	fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
451
-
452
-	fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
453
-
454
-	fmt.Println("> Add(4,5)的结果为:", ret)
455
-	handle.Release()
456
-
457
-	return "", nil
247
+//func (c *HisApiController) Sscard() {
248
+//	//id_card_type, _ := c.GetInt64("id_card_type")
249
+//	//adminUser := c.GetAdminUserInfo()
250
+//	//miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
251
+//	id_card_type := 1
252
+//	r := CardInit()
253
+//	fmt.Println(r)
254
+//	//if r == 0 {
255
+//	switch id_card_type {
256
+//	case 1:
257
+//		defer GetBasBaseInfo()
258
+//
259
+//		//if err != nil {
260
+//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
261
+//		//	return
262
+//		//
263
+//		//} else {
264
+//		//	fmt.Println(basStr)
265
+//		//
266
+//		//	bas := strings.Split(basStr, "|")
267
+//		//
268
+//		//	basNumber := bas[1]
269
+//		//
270
+//		//	//basNumber := bas[2]
271
+//		//	card_sn := bas[3]
272
+//		//
273
+//		//	appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
274
+//		//
275
+//		//	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
276
+//		//	resp, requestErr := http.Get(api)
277
+//		//	if requestErr != nil {
278
+//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
279
+//		//		return
280
+//		//	}
281
+//		//	defer resp.Body.Close()
282
+//		//	body, ioErr := ioutil.ReadAll(resp.Body)
283
+//		//	if ioErr != nil {
284
+//		//		utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
285
+//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
286
+//		//		return
287
+//		//	}
288
+//		//	var respJSON map[string]interface{}
289
+//		//
290
+//		//	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
291
+//		//		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
292
+//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
293
+//		//		return
294
+//		//	}
295
+//		//
296
+//		//	userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
297
+//		//	userJSONBytes, _ := json.Marshal(userJSON)
298
+//		//	var res ResultTwo
299
+//		//	if err := json.Unmarshal(userJSONBytes, &res); err != nil {
300
+//		//		utils.ErrorLog("解析失败:%v", err)
301
+//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
302
+//		//		return
303
+//		//	}
304
+//		//	Iinfos, _ := json.Marshal(res.Output.Iinfo)
305
+//		//	Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
306
+//		//	infoStr := string(Iinfos)
307
+//		//	idetinfoStr := string(Idetinfos)
308
+//		//
309
+//		//	if res.Infcode == 0 {
310
+//		//		his := models.VMHisPatient{
311
+//		//			Status:      1,
312
+//		//			Ctime:       time.Now().Unix(),
313
+//		//			Mtime:       time.Now().Unix(),
314
+//		//			PsnNo:       res.Output.Baseinfo.PsnNo,
315
+//		//			PsnCertType: res.Output.Baseinfo.PsnCertType,
316
+//		//			Certno:      res.Output.Baseinfo.Certno,
317
+//		//			PsnName:     res.Output.Baseinfo.PsnName,
318
+//		//			Gend:        res.Output.Baseinfo.Gend,
319
+//		//			Naty:        res.Output.Baseinfo.Naty,
320
+//		//			Brdy:        res.Output.Baseinfo.Brdy,
321
+//		//			Age:         res.Output.Baseinfo.Age,
322
+//		//			Iinfo:       infoStr,
323
+//		//			Idetinfo:    idetinfoStr,
324
+//		//			UserOrgId:   adminUser.CurrentOrgId,
325
+//		//			IsReturn:    1,
326
+//		//			IdCardType:  id_card_type,
327
+//		//		}
328
+//		//
329
+//		//		patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
330
+//		//		if err == gorm.ErrRecordNotFound {
331
+//		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
332
+//		//			return
333
+//		//
334
+//		//		} else if err != nil {
335
+//		//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
336
+//		//			return
337
+//		//
338
+//		//		} else {
339
+//		//			c.ServeSuccessJSON(map[string]interface{}{
340
+//		//				"patient": patient,
341
+//		//				"his":     his,
342
+//		//				"number":  basNumber,
343
+//		//			})
344
+//		//		}
345
+//		//	} else {
346
+//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
347
+//		//		return
348
+//		//	}
349
+//		//
350
+//		//}
351
+//
352
+//		break
353
+//	case 2:
354
+//		////SFZStr, err := GetSFZBaseInfo()
355
+//		//if err != nil {
356
+//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
357
+//		//	return
358
+//		//
359
+//		//} else {
360
+//		//
361
+//		//	id_card_str := strings.Split(SFZStr, "^")
362
+//		//	id_card_number := id_card_str[0]
363
+//		//appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
364
+//		//
365
+//		//api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&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)
366
+//		//resp, requestErr := http.Get(api)
367
+//		//if requestErr != nil {
368
+//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
369
+//		//	return
370
+//		//}
371
+//		//defer resp.Body.Close()
372
+//		//body, ioErr := ioutil.ReadAll(resp.Body)
373
+//		//if ioErr != nil {
374
+//		//	utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
375
+//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
376
+//		//	return
377
+//		//}
378
+//		//var respJSON map[string]interface{}
379
+//		//
380
+//		//if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
381
+//		//	utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
382
+//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
383
+//		//	return
384
+//		//}
385
+//		//
386
+//		//userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
387
+//		//userJSONBytes, _ := json.Marshal(userJSON)
388
+//		//var res ResultTwo
389
+//		//if err := json.Unmarshal(userJSONBytes, &res); err != nil {
390
+//		//	utils.ErrorLog("解析失败:%v", err)
391
+//		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
392
+//		//	return
393
+//		//}
394
+//		//Iinfos, _ := json.Marshal(res.Output.Iinfo)
395
+//		//Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
396
+//		//infoStr := string(Iinfos)
397
+//		//idetinfoStr := string(Idetinfos)
398
+//		//
399
+//		//if res.Infcode == 0 {
400
+//		//	his := models.VMHisPatient{
401
+//		//		Status:      1,
402
+//		//		Ctime:       time.Now().Unix(),
403
+//		//		Mtime:       time.Now().Unix(),
404
+//		//		PsnNo:       res.Output.Baseinfo.PsnNo,
405
+//		//		PsnCertType: res.Output.Baseinfo.PsnCertType,
406
+//		//		Certno:      res.Output.Baseinfo.Certno,
407
+//		//		PsnName:     res.Output.Baseinfo.PsnName,
408
+//		//		Gend:        res.Output.Baseinfo.Gend,
409
+//		//		Naty:        res.Output.Baseinfo.Naty,
410
+//		//		Brdy:        res.Output.Baseinfo.Brdy,
411
+//		//		Age:         res.Output.Baseinfo.Age,
412
+//		//		Iinfo:       infoStr,
413
+//		//		Idetinfo:    idetinfoStr,
414
+//		//		UserOrgId:   adminUser.CurrentOrgId,
415
+//		//		IsReturn:    1,
416
+//		//		IdCardType:  id_card_type,
417
+//		//	}
418
+//
419
+//		//	patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
420
+//		//	if err == gorm.ErrRecordNotFound {
421
+//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
422
+//		//		return
423
+//		//
424
+//		//	} else if err != nil {
425
+//		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
426
+//		//		return
427
+//		//
428
+//		//	} else {
429
+//		//		c.ServeSuccessJSON(map[string]interface{}{
430
+//		//			"patient": patient,
431
+//		//			"number":  id_card_number,
432
+//		//		})
433
+//		//	}
434
+//		//}
435
+//		break
436
+//	case 3:
437
+//
438
+//		break
439
+//
440
+//	}
441
+//}
458 442
 
459
-}
443
+//func GetBasBaseInfo() (jsonStr string, err error) {
444
+//
445
+//	handle := syscall.NewLazyDLL("SSCard.dll")
446
+//	add := handle.NewProc("ReadCardBas")
447
+//	str := make([]byte, 1024)
448
+//	str1 := make([]byte, 1024)
449
+//	ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
450
+//	fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
451
+//
452
+//	fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
453
+//
454
+//	fmt.Println("> Add(4,5)的结果为:", ret)
455
+//	handle.Release()
456
+//
457
+//	return "", nil
458
+//
459
+//}
460 460
 
461 461
 //func GetSFZBaseInfo() (jsonStr string, err error) {
462 462
 //	//handle := syscall.MustLoadDLL("SSCard.dll")
@@ -482,16 +482,16 @@ func GetBasBaseInfo() (jsonStr string, err error) {
482 482
 //	return string(str), nil
483 483
 //}
484 484
 
485
-func CardInit() int {
486
-	DllTestDef := syscall.MustLoadDLL("SSCard.dll")
487
-	add := DllTestDef.MustFindProc("Init")
488
-	ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
489
-	if err != nil {
490
-		fmt.Println("SSCard的运算结果为:", ret)
491
-	}
492
-	result := int(ret)
493
-	return result
494
-}
485
+//func CardInit() int {
486
+//	DllTestDef := syscall.MustLoadDLL("SSCard.dll")
487
+//	add := DllTestDef.MustFindProc("Init")
488
+//	ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
489
+//	if err != nil {
490
+//		fmt.Println("SSCard的运算结果为:", ret)
491
+//	}
492
+//	result := int(ret)
493
+//	return result
494
+//}
495 495
 
496 496
 //func CardInit() int {
497 497
 //	ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))