Browse Source

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

csx 3 years ago
parent
commit
40dc4c109a
3 changed files with 45 additions and 53 deletions
  1. 24 35
      controllers/sg/his_api_controller.go
  2. 6 5
      main.go
  3. 15 13
      models/his_models.go

+ 24 - 35
controllers/sg/his_api_controller.go View File

@@ -364,42 +364,26 @@ func (c *HisApiController) ReadCard() {
364 364
 				return
365 365
 			}
366 366
 			var status string
367
-			respJSON = respJSON["data"].(map[string]interface{})["status"].(map[string]interface{})
368
-			result, _ := json.Marshal(respJSON)
369
-			if err := json.Unmarshal([]byte(result), &status); err != nil {
370
-				utils.ErrorLog("解析失败:%v", err)
371
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
372
-				return
373
-			}
367
+			status = respJSON["data"].(map[string]interface{})["status"].(string)
368
+
374 369
 			if status == "0" { //读卡成功
375 370
 				var card_info string //卡信息
376 371
 				var busi_card_info string
377 372
 				var res ResultTwo //1101结果
378 373
 
379
-				respJSON = respJSON["data"].(map[string]interface{})["card_info"].(map[string]interface{})
380
-				card_info_result, _ := json.Marshal(respJSON)
374
+				card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
375
+				busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
381 376
 
382
-				respJSON = respJSON["data"].(map[string]interface{})["busi_card_info"].(map[string]interface{})
383
-				busi_card_info_result, _ := json.Marshal(respJSON)
377
+				fmt.Println(card_info)
378
+				fmt.Println(busi_card_info)
384 379
 
385 380
 				respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
386 381
 				result, _ := json.Marshal(respJSON)
387
-
388 382
 				if err := json.Unmarshal([]byte(result), &res); err != nil {
389 383
 					utils.ErrorLog("解析失败:%v", err)
390 384
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
391 385
 					return
392 386
 				}
393
-				if err := json.Unmarshal([]byte(card_info_result), &card_info); err != nil {
394
-					utils.ErrorLog("解析失败:%v", err)
395
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
396
-					return
397
-				}
398
-				if err := json.Unmarshal([]byte(busi_card_info_result), &busi_card_info); err != nil {
399
-					utils.ErrorLog("解析失败:%v", err)
400
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
401
-					return
402
-				}
403 387
 
404 388
 				if res.Infcode == 0 {
405 389
 					patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
@@ -412,28 +396,33 @@ func (c *HisApiController) ReadCard() {
412 396
 
413 397
 					} else {
414 398
 
399
+						bas := strings.Split(card_info, "|")
400
+						basNumber := bas[2]
401
+
415 402
 						Iinfos, _ := json.Marshal(res.Output.Iinfo)
416 403
 						Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
417 404
 						infoStr := string(Iinfos)
418 405
 						idetinfoStr := string(Idetinfos)
419 406
 						psn := &models.HisPsn{
420
-							PsnNo:       res.Output.Baseinfo.PsnNo,
421
-							Age:         res.Output.Baseinfo.Age,
422
-							PatientId:   patient.ID,
423
-							Certno:      res.Output.Baseinfo.Certno,
424
-							Brdy:        res.Output.Baseinfo.Brdy,
425
-							Gend:        res.Output.Baseinfo.Gend,
426
-							Naty:        res.Output.Baseinfo.Naty,
427
-							PsnCertType: res.Output.Baseinfo.PsnCertType,
428
-							PsnName:     res.Output.Baseinfo.PsnName,
429
-							Idetinfo:    idetinfoStr,
430
-							Insuinfo:    infoStr,
431
-							UserOrgId:   c.GetAdminUserInfo().CurrentOrgId,
407
+							PsnNo:        res.Output.Baseinfo.PsnNo,
408
+							Age:          res.Output.Baseinfo.Age,
409
+							PatientId:    patient.ID,
410
+							Certno:       res.Output.Baseinfo.Certno,
411
+							Brdy:         res.Output.Baseinfo.Brdy,
412
+							Gend:         res.Output.Baseinfo.Gend,
413
+							Naty:         res.Output.Baseinfo.Naty,
414
+							PsnCertType:  res.Output.Baseinfo.PsnCertType,
415
+							PsnName:      res.Output.Baseinfo.PsnName,
416
+							Idetinfo:     idetinfoStr,
417
+							Insuinfo:     infoStr,
418
+							UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
419
+							CardInfo:     card_info,
420
+							VerifyNumber: busi_card_info,
432 421
 						}
433 422
 						service.CreateHisPsn(psn)
434 423
 						c.ServeSuccessJSON(map[string]interface{}{
435 424
 							"patient": patient,
436
-							"number":  res.Output.Baseinfo.Certno,
425
+							"number":  basNumber,
437 426
 						})
438 427
 					}
439 428
 				} else {

+ 6 - 5
main.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"fmt"
6 6
 	"gdyb/models"
7 7
 	_ "gdyb/routers"
8
+	"gdyb/service"
8 9
 	"github.com/astaxie/beego"
9 10
 	"github.com/qiniu/api.v7/auth/qbox"
10 11
 	"github.com/qiniu/api.v7/storage"
@@ -14,11 +15,11 @@ import (
14 15
 )
15 16
 
16 17
 func init() {
17
-	//service.ConnectDB()
18
-	//org_id, _ := beego.AppConfig.Int64("org_id")
19
-	//miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
20
-	//CreateLog(miConfig)
21
-	//UploadLog(miConfig)
18
+	service.ConnectDB()
19
+	org_id, _ := beego.AppConfig.Int64("org_id")
20
+	miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
21
+	CreateLog(miConfig)
22
+	UploadLog(miConfig)
22 23
 
23 24
 }
24 25
 func main() {

+ 15 - 13
models/his_models.go View File

@@ -1276,19 +1276,21 @@ type NewCustom struct {
1276 1276
 }
1277 1277
 
1278 1278
 type HisPsn struct {
1279
-	ID          int64   `gorm:"column:id" json:"id" form:"id"`
1280
-	PsnNo       string  `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
1281
-	Age         float64 `gorm:"column:age" json:"age" form:"age"`
1282
-	PatientId   int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1283
-	Certno      string  `gorm:"column:certno" json:"certno" form:"certno"`
1284
-	Brdy        string  `gorm:"column:brdy" json:"brdy" form:"brdy"`
1285
-	Gend        string  `gorm:"column:gend" json:"gend" form:"gend"`
1286
-	Naty        string  `gorm:"column:naty" json:"naty" form:"naty"`
1287
-	PsnCertType string  `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
1288
-	PsnName     string  `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
1289
-	Idetinfo    string  `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
1290
-	Insuinfo    string  `gorm:"column:insuinfo" json:"insuinfo" form:"insuinfo"`
1291
-	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1279
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
1280
+	PsnNo        string  `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
1281
+	Age          float64 `gorm:"column:age" json:"age" form:"age"`
1282
+	PatientId    int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1283
+	Certno       string  `gorm:"column:certno" json:"certno" form:"certno"`
1284
+	Brdy         string  `gorm:"column:brdy" json:"brdy" form:"brdy"`
1285
+	Gend         string  `gorm:"column:gend" json:"gend" form:"gend"`
1286
+	Naty         string  `gorm:"column:naty" json:"naty" form:"naty"`
1287
+	PsnCertType  string  `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
1288
+	PsnName      string  `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
1289
+	Idetinfo     string  `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
1290
+	Insuinfo     string  `gorm:"column:insuinfo" json:"insuinfo" form:"insuinfo"`
1291
+	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1292
+	CardInfo     string  `gorm:"column:card_info" json:"card_info" form:"card_info"`
1293
+	VerifyNumber string  `gorm:"column:verify_number" json:"verify_number" form:"verify_number"`
1292 1294
 }
1293 1295
 
1294 1296
 func (HisPsn) TableName() string {