csx 2 years ago
parent
commit
e0d1df2629
6 changed files with 40 additions and 40 deletions
  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 View File

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

+ 4 - 4
service/cron.go View File

57
 
57
 
58
 // 返回一个支持至 秒 级别的 cron
58
 // 返回一个支持至 秒 级别的 cron
59
 func newWithSeconds() *cron.Cron {
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
 func BeginAutoSyncLis() {
65
 func BeginAutoSyncLis() {
66
 	utils.InfoLog("开启自动检验检查同步定时任务")
66
 	utils.InfoLog("开启自动检验检查同步定时任务")
67
 	createLisSyncCronJob := newWithSeconds()
67
 	createLisSyncCronJob := newWithSeconds()
68
-	 
68
+
69
 	specgzjh := "0 */1 * * * ?" // 每1分钟同步 广州暨华HIS医嘱
69
 	specgzjh := "0 */1 * * * ?" // 每1分钟同步 广州暨华HIS医嘱
70
 	createLisSyncCronJob.AddFunc(specgzjh, func() {
70
 	createLisSyncCronJob.AddFunc(specgzjh, func() {
71
 		SyncGzjhyz()
71
 		SyncGzjhyz()

+ 0 - 1
service/db.go View File

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

+ 4 - 4
service/ms_db.go View File

28
 
28
 
29
 var (
29
 var (
30
 	dbName   = "local"
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
 	port     = beego.AppConfig.DefaultInt(dbName+"::port", 1633)
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
 func ConnectSHMSDB() {
38
 func ConnectSHMSDB() {

+ 1 - 1
service/redis.go View File

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

+ 28 - 28
service/ystx_service.go View File

497
 func GetGzjhYz(sync_time int64, his_user_id string) (str gzjhResult, checkStr string) {
497
 func GetGzjhYz(sync_time int64, his_user_id string) (str gzjhResult, checkStr string) {
498
 	apiurl := "http://219.135.166.106:8067/WebService.asmx/queryyzxx"
498
 	apiurl := "http://219.135.166.106:8067/WebService.asmx/queryyzxx"
499
 	rep := httplib.Get(apiurl)
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
 	rep.Param("his_user_id", his_user_id)
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
 	utils.InfoLog(his_user_id)
504
 	utils.InfoLog(his_user_id)
505
 	// str, _ := rep.String()
505
 	// str, _ := rep.String()
506
 	xmlKey := XmlKey{}
506
 	xmlKey := XmlKey{}
528
 
528
 
529
 	redisClient := RedisClient()
529
 	redisClient := RedisClient()
530
 	defer redisClient.Close()
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
 	if sync_time == 0 {
534
 	if sync_time == 0 {
535
 		sync_time = time.Now().Unix()
535
 		sync_time = time.Now().Unix()
536
 	}
536
 	}
537
 	new_sync_time := time.Now().Unix()
537
 	new_sync_time := time.Now().Unix()
538
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
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
 	schedulesDateStr := time.Now().Format("2006-01-02")
542
 	schedulesDateStr := time.Now().Format("2006-01-02")
543
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
543
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
545
 	var patient_zy_ids string
545
 	var patient_zy_ids string
546
 	// patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
546
 	// patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
547
 	// if len(patient_zy_ids) == 0 {
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
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
562
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
563
 
563
 
569
 		patient_id := temp_id[1]
569
 		patient_id := temp_id[1]
570
 		admission_number := temp_id[2]
570
 		admission_number := temp_id[2]
571
 		gzjhyz, yzstr := GetGzjhYz(sync_time, id)
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
 			utils.InfoLog("admission_number:%v", admission_number)
573
 			utils.InfoLog("admission_number:%v", admission_number)
574
 			gzjhyz, yzstr = GetGzjhYz(sync_time, admission_number)
574
 			gzjhyz, yzstr = GetGzjhYz(sync_time, admission_number)
575
 		}
575
 		}
581
 			for _, yz := range gzjhyz.Result {
581
 			for _, yz := range gzjhyz.Result {
582
 				// 根据姓名获取医生ID
582
 				// 根据姓名获取医生ID
583
 				var doctor_id int64
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
 				if len(temp_doctor_id) == 0 {
585
 				if len(temp_doctor_id) == 0 {
586
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorId)
586
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorId)
587
 					doctor_id = doctor.AdminUserId
587
 					doctor_id = doctor.AdminUserId
588
 					if doctor_id > 0 {
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
 					} else {
590
 					} else {
591
 						continue
591
 						continue
592
 					}
592
 					}
628
 				if advice_info.ID > 0 {
628
 				if advice_info.ID > 0 {
629
 					key := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(temp_patient_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":doctor_advices"
629
 					key := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(temp_patient_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":doctor_advices"
630
 					//清空key 值
630
 					//清空key 值
631
-					redisClient.Set(redisClient.Context(),key, "", time.Second)
631
+					redisClient.Set(key, "", time.Second)
632
 					keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":advice_list_all"
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
 					continue
634
 					continue
635
 				} else {
635
 				} else {
636
 					if len(yz.AdviceName) > 0 {
636
 					if len(yz.AdviceName) > 0 {
918
 
918
 
919
 	redisClient := RedisClient()
919
 	redisClient := RedisClient()
920
 	defer redisClient.Close()
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
 	if len(sync_time) == 0 {
922
 	if len(sync_time) == 0 {
923
 		sync_time = strconv.FormatInt(time.Now().Unix(), 10)
923
 		sync_time = strconv.FormatInt(time.Now().Unix(), 10)
924
 		utils.InfoLog("sync_time:%v", sync_time)
924
 		utils.InfoLog("sync_time:%v", sync_time)
929
 	new_sync_time := time.Now().Unix()
929
 	new_sync_time := time.Now().Unix()
930
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
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
 	schedulesDateStr := time.Now().Format("2006-01-02")
934
 	schedulesDateStr := time.Now().Format("2006-01-02")
935
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
935
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
936
 	schedulesTime := schedulesDate.Unix()
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
 	if len(patient_zy_ids) == 0 {
938
 	if len(patient_zy_ids) == 0 {
939
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
939
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
940
 		if len(schedules) > 0 {
940
 		if len(schedules) > 0 {
945
 					patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
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
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
951
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
962
 				utils.InfoLog("yz:%v", yz)
962
 				utils.InfoLog("yz:%v", yz)
963
 				// 根据姓名获取医生ID
963
 				// 根据姓名获取医生ID
964
 				var doctor_id int64
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
 				if len(temp_doctor_id) == 0 {
966
 				if len(temp_doctor_id) == 0 {
967
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorName)
967
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorName)
968
 					doctor_id = doctor.AdminUserId
968
 					doctor_id = doctor.AdminUserId
969
 					if doctor_id > 0 {
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
 					} else {
971
 					} else {
972
 						continue
972
 						continue
973
 					}
973
 					}