csx 2 vuotta sitten
vanhempi
commit
e0d1df2629
6 muutettua tiedostoa jossa 40 lisäystä ja 40 poistoa
  1. 3 2
      main.go
  2. 4 4
      service/cron.go
  3. 0 1
      service/db.go
  4. 4 4
      service/ms_db.go
  5. 1 1
      service/redis.go
  6. 28 28
      service/ystx_service.go

+ 3 - 2
main.go Näytä tiedosto

@@ -8,13 +8,14 @@ import (
8 8
 
9 9
 func init() {
10 10
 	service.ConnectDB()
11
+	service.ConnectSHMSDB()
11 12
 	// service.ConnectMSDB()
12 13
 }
13 14
 
14 15
 func main() {
15
-	service.BeginAutoSyncLis()
16
+	//service.BeginAutoSyncLis()
16 17
 	//service.GetDataInsertDB(10138)
17 18
 	//service.GetResultDataInsertDB(10138)
18
-
19
+	service.GetSHResultDataInsertDB(10215)
19 20
 	beego.Run()
20 21
 }

+ 4 - 4
service/cron.go Näytä tiedosto

@@ -57,15 +57,15 @@ func init() {
57 57
 
58 58
 // 返回一个支持至 秒 级别的 cron
59 59
 func newWithSeconds() *cron.Cron {
60
-    secondParser := cron.NewParser(cron.Second | cron.Minute |
61
-        cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)
62
-    return cron.New(cron.WithParser(secondParser), cron.WithChain())
60
+	secondParser := cron.NewParser(cron.Second | cron.Minute |
61
+		cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)
62
+	return cron.New(cron.WithParser(secondParser), cron.WithChain())
63 63
 }
64 64
 
65 65
 func BeginAutoSyncLis() {
66 66
 	utils.InfoLog("开启自动检验检查同步定时任务")
67 67
 	createLisSyncCronJob := newWithSeconds()
68
-	 
68
+
69 69
 	specgzjh := "0 */1 * * * ?" // 每1分钟同步 广州暨华HIS医嘱
70 70
 	createLisSyncCronJob.AddFunc(specgzjh, func() {
71 71
 		SyncGzjhyz()

+ 0 - 1
service/db.go Näytä tiedosto

@@ -219,7 +219,6 @@ func ConnectDB() {
219 219
 	shDb, err = gorm.Open("mysql", shdsn)
220 220
 	if err != nil {
221 221
 		fmt.Println("12344")
222
-		fmt.Println(bldsn)
223 222
 
224 223
 		fmt.Println(err)
225 224
 	}

+ 4 - 4
service/ms_db.go Näytä tiedosto

@@ -28,11 +28,11 @@ var dataBase *gorm.DB
28 28
 
29 29
 var (
30 30
 	dbName   = "local"
31
-	user     = beego.AppConfig.DefaultString(dbName+"::user", "sa")
32
-	password = beego.AppConfig.DefaultString(dbName+"::password", "hy123456")
33
-	host     = beego.AppConfig.DefaultString(dbName+"::host", "192.168.10.10")
31
+	user     = beego.AppConfig.DefaultString(dbName+"::user", "KingMed")
32
+	password = beego.AppConfig.DefaultString(dbName+"::password", "KingMed")
33
+	host     = beego.AppConfig.DefaultString(dbName+"::host", "192.168.10.80")
34 34
 	port     = beego.AppConfig.DefaultInt(dbName+"::port", 1633)
35
-	dbname   = beego.AppConfig.DefaultString(dbName+"::dbname", "hyDB")
35
+	dbname   = beego.AppConfig.DefaultString(dbName+"::dbname", "KMDB")
36 36
 )
37 37
 
38 38
 func ConnectSHMSDB() {

+ 1 - 1
service/redis.go Näytä tiedosto

@@ -14,7 +14,7 @@ func RedisClient() *redis.Client {
14 14
 		Password: beego.AppConfig.String("redispasswrod"), // no password set
15 15
 		DB:       0,                                       // use default DB
16 16
 	})
17
-	pong, err := client.Ping(client.Context()).Result()
17
+	pong, err := client.Ping().Result()
18 18
 	fmt.Println(pong, err)
19 19
 	return client
20 20
 }

+ 28 - 28
service/ystx_service.go Näytä tiedosto

@@ -497,10 +497,10 @@ type gzjhyz struct {
497 497
 func GetGzjhYz(sync_time int64, his_user_id string) (str gzjhResult, checkStr string) {
498 498
 	apiurl := "http://219.135.166.106:8067/WebService.asmx/queryyzxx"
499 499
 	rep := httplib.Get(apiurl)
500
-	rep.Param("sync_time", strconv.FormatInt(sync_time,10))
501
-	rep.Param("access_token","0")
500
+	rep.Param("sync_time", strconv.FormatInt(sync_time, 10))
501
+	rep.Param("access_token", "0")
502 502
 	rep.Param("his_user_id", his_user_id)
503
-	utils.InfoLog(strconv.FormatInt(sync_time,10))
503
+	utils.InfoLog(strconv.FormatInt(sync_time, 10))
504 504
 	utils.InfoLog(his_user_id)
505 505
 	// str, _ := rep.String()
506 506
 	xmlKey := XmlKey{}
@@ -528,16 +528,16 @@ func SyncGzjhyz() (err error) {
528 528
 
529 529
 	redisClient := RedisClient()
530 530
 	defer redisClient.Close()
531
-	sync_time_tt, _ := redisClient.Get(redisClient.Context(),"gdjh_sync_time").Result()
531
+	sync_time_tt, _ := redisClient.Get("gdjh_sync_time").Result()
532 532
 
533
-	sync_time,_ := strconv.ParseInt(sync_time_tt,10,64)
533
+	sync_time, _ := strconv.ParseInt(sync_time_tt, 10, 64)
534 534
 	if sync_time == 0 {
535 535
 		sync_time = time.Now().Unix()
536 536
 	}
537 537
 	new_sync_time := time.Now().Unix()
538 538
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
539 539
 	// 切换为当前时间
540
-	redisClient.Set(redisClient.Context(),"gdjh_sync_time", new_sync_time, time.Minute*60*24)
540
+	redisClient.Set("gdjh_sync_time", new_sync_time, time.Minute*60*24)
541 541
 	// 第二步: 获取当天排班患者的住院号
542 542
 	schedulesDateStr := time.Now().Format("2006-01-02")
543 543
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
@@ -545,19 +545,19 @@ func SyncGzjhyz() (err error) {
545 545
 	var patient_zy_ids string
546 546
 	// patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
547 547
 	// if len(patient_zy_ids) == 0 {
548
-		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
549
-		if len(schedules) > 0 {
550
-			for _, item := range schedules {
551
-				// if len(item.Patients.AdmissionNumber) > 0 {
552
-					if len(patient_zy_ids) == 0 {
553
-						patient_zy_ids = item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
554
-					} else {
555
-						patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
556
-					}
557
-				// }
548
+	schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
549
+	if len(schedules) > 0 {
550
+		for _, item := range schedules {
551
+			// if len(item.Patients.AdmissionNumber) > 0 {
552
+			if len(patient_zy_ids) == 0 {
553
+				patient_zy_ids = item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
554
+			} else {
555
+				patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
558 556
 			}
559
-			// redisClient.Set(redisClient.Context(),"gdjh_patient_zy_ids", patient_zy_ids, time.Minute*5)
557
+			// }
560 558
 		}
559
+		// redisClient.Set(redisClient.Context(),"gdjh_patient_zy_ids", patient_zy_ids, time.Minute*5)
560
+	}
561 561
 	// }
562 562
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
563 563
 
@@ -569,7 +569,7 @@ func SyncGzjhyz() (err error) {
569 569
 		patient_id := temp_id[1]
570 570
 		admission_number := temp_id[2]
571 571
 		gzjhyz, yzstr := GetGzjhYz(sync_time, id)
572
-		if len(gzjhyz.Result) == 0 && len(admission_number) > 0{
572
+		if len(gzjhyz.Result) == 0 && len(admission_number) > 0 {
573 573
 			utils.InfoLog("admission_number:%v", admission_number)
574 574
 			gzjhyz, yzstr = GetGzjhYz(sync_time, admission_number)
575 575
 		}
@@ -581,12 +581,12 @@ func SyncGzjhyz() (err error) {
581 581
 			for _, yz := range gzjhyz.Result {
582 582
 				// 根据姓名获取医生ID
583 583
 				var doctor_id int64
584
-				temp_doctor_id, _ := redisClient.Get(redisClient.Context(),"gdjh_doctor_id_" + yz.DoctorId).Result()
584
+				temp_doctor_id, _ := redisClient.Get("gdjh_doctor_id_" + yz.DoctorId).Result()
585 585
 				if len(temp_doctor_id) == 0 {
586 586
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorId)
587 587
 					doctor_id = doctor.AdminUserId
588 588
 					if doctor_id > 0 {
589
-						redisClient.Set(redisClient.Context(),"gdjh_doctor_id_"+yz.DoctorId, doctor_id, time.Minute*60*2)
589
+						redisClient.Set("gdjh_doctor_id_"+yz.DoctorId, doctor_id, time.Minute*60*2)
590 590
 					} else {
591 591
 						continue
592 592
 					}
@@ -628,9 +628,9 @@ func SyncGzjhyz() (err error) {
628 628
 				if advice_info.ID > 0 {
629 629
 					key := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(temp_patient_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":doctor_advices"
630 630
 					//清空key 值
631
-					redisClient.Set(redisClient.Context(),key, "", time.Second)
631
+					redisClient.Set(key, "", time.Second)
632 632
 					keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":advice_list_all"
633
-					redisClient.Set(redisClient.Context(),keyOne, "", time.Second)
633
+					redisClient.Set(keyOne, "", time.Second)
634 634
 					continue
635 635
 				} else {
636 636
 					if len(yz.AdviceName) > 0 {
@@ -918,7 +918,7 @@ func SyncHbJldyyz() (err error) {
918 918
 
919 919
 	redisClient := RedisClient()
920 920
 	defer redisClient.Close()
921
-	sync_time, _ := redisClient.Get(redisClient.Context(),"gdjh_sync_time1").Result()
921
+	sync_time, _ := redisClient.Get("gdjh_sync_time1").Result()
922 922
 	if len(sync_time) == 0 {
923 923
 		sync_time = strconv.FormatInt(time.Now().Unix(), 10)
924 924
 		utils.InfoLog("sync_time:%v", sync_time)
@@ -929,12 +929,12 @@ func SyncHbJldyyz() (err error) {
929 929
 	new_sync_time := time.Now().Unix()
930 930
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
931 931
 	// 切换为当前时间
932
-	redisClient.Set(redisClient.Context(),"gdjh_sync_time", new_sync_time, time.Minute*60*24)
932
+	redisClient.Set("gdjh_sync_time", new_sync_time, time.Minute*60*24)
933 933
 	// 第二步: 获取当天排班患者的住院号
934 934
 	schedulesDateStr := time.Now().Format("2006-01-02")
935 935
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
936 936
 	schedulesTime := schedulesDate.Unix()
937
-	patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
937
+	patient_zy_ids, _ := redisClient.Get("gdjh_patient_zy_ids").Result()
938 938
 	if len(patient_zy_ids) == 0 {
939 939
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
940 940
 		if len(schedules) > 0 {
@@ -945,7 +945,7 @@ func SyncHbJldyyz() (err error) {
945 945
 					patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
946 946
 				}
947 947
 			}
948
-			redisClient.Set(redisClient.Context(),"gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
948
+			redisClient.Set("gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
949 949
 		}
950 950
 	}
951 951
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
@@ -962,12 +962,12 @@ func SyncHbJldyyz() (err error) {
962 962
 				utils.InfoLog("yz:%v", yz)
963 963
 				// 根据姓名获取医生ID
964 964
 				var doctor_id int64
965
-				temp_doctor_id, _ := redisClient.Get(redisClient.Context(),"gdjh_doctor_id_" + strconv.FormatInt(yz.DoctorId, 10)).Result()
965
+				temp_doctor_id, _ := redisClient.Get("gdjh_doctor_id_" + strconv.FormatInt(yz.DoctorId, 10)).Result()
966 966
 				if len(temp_doctor_id) == 0 {
967 967
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorName)
968 968
 					doctor_id = doctor.AdminUserId
969 969
 					if doctor_id > 0 {
970
-						redisClient.Set(redisClient.Context(),"gdjh_doctor_id_"+strconv.FormatInt(yz.DoctorId, 10), doctor_id, time.Minute*60*2)
970
+						redisClient.Set("gdjh_doctor_id_"+strconv.FormatInt(yz.DoctorId, 10), doctor_id, time.Minute*60*2)
971 971
 					} else {
972 972
 						continue
973 973
 					}