张保健 2 years ago
parent
commit
2252e13cc4
10 changed files with 197 additions and 85 deletions
  1. 14 8
      conf/app.conf
  2. 18 1
      controllers/lis.go
  3. 1 1
      main.go
  4. 20 0
      models/lis_model.go
  5. 1 0
      routers/router.go
  6. 53 27
      service/cron.go
  7. 36 20
      service/db.go
  8. 11 0
      service/lis_service.go
  9. 1 1
      service/redis.go
  10. 42 27
      service/ystx_service.go

+ 14 - 8
conf/app.conf View File

@@ -30,11 +30,11 @@ httpdomain = https://api.xt.kuyicloud.com
30 30
 sso_domain = https://sso.kuyicloud.com
31 31
 front_end_domain = "https://xt.kuyicloud.com/#"
32 32
 
33
-blmysqlhost = 192.168.10.10
34
-blmysqlport = 3306
35
-blmysqluser = root
36
-blmysqlpass = 12345678
37
-blmysqlname = kuyicloud
33
+# blmysqlhost = 192.168.10.10
34
+# blmysqlport = 3306
35
+# blmysqluser = root
36
+# blmysqlpass = 12345678
37
+# blmysqlname = kuyicloud
38 38
 
39 39
 
40 40
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
@@ -49,6 +49,12 @@ writemysqluser = syh
49 49
 writemysqlpass = xhPECP2nFObR8aUK
50 50
 writemysqlname = sgj_xt
51 51
 
52
+tempwritemysqlhost = rm-wz930n4u3k76i95tuuo.mysql.rds.aliyuncs.com
53
+tempwritemysqlport = 3306
54
+tempwritemysqluser = syh
55
+tempwritemysqlpass = xhPECP2nFObR8aUK
56
+tempwritemysqlname = sgj_xt
57
+
52 58
 readremotehost = 219.135.207.166
53 59
 readremoteport = 1433
54 60
 readremoteuser = lis_xt
@@ -87,10 +93,10 @@ backuppass = xhPECP2nFObR8aUK
87 93
 backupname = sgj_xt
88 94
 
89 95
 
90
-redishost = kuyi6666.redis.rds.aliyuncs.com
96
+redishost = kuyicloud.redis.rds.aliyuncs.com
91 97
 redisport = 6379
92
-redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
93
-redisdb = 2
98
+redispasswrod = 1Q2W3e4r!@#$
99
+redisdb = 1
94 100
 
95 101
 
96 102
 

+ 18 - 1
controllers/lis.go View File

@@ -6,7 +6,7 @@ import (
6 6
 	"IC/service"
7 7
 	"IC/utils"
8 8
 	"encoding/json"
9
-	_ "fmt"
9
+	"fmt"
10 10
 	_ "github.com/astaxie/beego"
11 11
 	_ "github.com/jinzhu/gorm"
12 12
 	_ "strconv"
@@ -18,6 +18,23 @@ type LisController struct {
18 18
 	BaseAPIController
19 19
 }
20 20
 
21
+func (c *LisController) Schedule() {
22
+	for i := 762429; i > 0; i-- {
23
+		schedule,err := service.GetScheduless(int64(i))
24
+		fmt.Println(schedule.ID)
25
+		if err == nil {
26
+			service.UpdateSchedule(schedule.ID,schedule.Status)
27
+		}
28
+		
29
+	}
30
+
31
+	c.ServeSuccessJSON(map[string]interface{}{
32
+		"resultList": "12345",
33
+	})
34
+	return
35
+
36
+}
37
+
21 38
 func (c *LisController) SyncAdvice() {
22 39
 	// 获取备份库里所有的医嘱信息
23 40
 	advices, _ := service.GetAllAdvice()

+ 1 - 1
main.go View File

@@ -8,7 +8,7 @@ import (
8 8
 
9 9
 func init() {
10 10
 	service.ConnectDB()
11
-	service.ConnectMSDB()
11
+	// service.ConnectMSDB()
12 12
 }
13 13
 
14 14
 func main() {

+ 20 - 0
models/lis_model.go View File

@@ -53,6 +53,26 @@ func (DoctorAdvice) TableName() string {
53 53
 	return "xt_doctor_advice"
54 54
 }
55 55
 
56
+type Schedules struct {
57
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
58
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
59
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
60
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
61
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
62
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
63
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
64
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
65
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
66
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
67
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
68
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
69
+	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
70
+}
71
+
72
+func (Schedules) TableName() string {
73
+	return "xt_schedule"
74
+}
75
+
56 76
 type FiledConfig struct {
57 77
 	ID          int64  `gorm:"column:id" json:"id"`
58 78
 	OrgId       int64  `gorm:"column:org_id" json:"org_id"`

+ 1 - 0
routers/router.go View File

@@ -21,5 +21,6 @@ func init() {
21 21
 	//百霖lis
22 22
 	beego.Router("/api/lis/bltest", &controllers.LisController{}, "get:SyncBlLis")
23 23
 	beego.Router("/api/lis/blresulttest", &controllers.LisController{}, "get:SyncBlResultLis")
24
+	beego.Router("/api/schedule", &controllers.LisController{}, "get:Schedule")
24 25
 
25 26
 }

+ 53 - 27
service/cron.go View File

@@ -12,15 +12,15 @@ import (
12 12
 )
13 13
 
14 14
 // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
15
-var createLisSyncCronJob *cron.Cron
15
+// var createLisSyncCronJob *cron.Cron
16 16
 
17 17
 func init() {
18
-	utils.InfoLog("开启自动检验检查同步定时任务")
19
-	createLisSyncCronJob = cron.New()
20
-	spec := "0 0 1 * * ?" // 每天凌晨1点同步
21
-	createLisSyncCronJob.AddFunc(spec, func() {
22
-		AutoSyncLis()
23
-	})
18
+	// utils.InfoLog("开启自动检验检查同步定时任务")
19
+	// createLisSyncCronJob = cron.New()
20
+	// spec := "0 0 1 * * ?" // 每天凌晨1点同步
21
+	// createLisSyncCronJob.AddFunc(spec, func() {
22
+	// 	AutoSyncLis()
23
+	// })
24 24
 
25 25
 	//speclg := "0 0 2 * * ?" // 每天凌晨2点同步 龙岗二院
26 26
 	//createLisSyncCronJob.AddFunc(speclg, func() {
@@ -32,8 +32,10 @@ func init() {
32 32
 	//	SyncHbdyLis()
33 33
 	//})
34 34
 
35
-	// specgzjh := "0 */1 7-20 * *  " // 每2分钟同步 广州暨华HIS医嘱
35
+	// utils.InfoLog("3333333")
36
+	// specgzjh := "1 * * * * ?" // 每1分钟同步 广州暨华HIS医嘱
36 37
 	// createLisSyncCronJob.AddFunc(specgzjh, func() {
38
+	// 	utils.InfoLog("1111111111")
37 39
 	// 	SyncGzjhyz()
38 40
 	// })
39 41
 
@@ -42,18 +44,42 @@ func init() {
42 44
 	//	SyncGzjhLis()
43 45
 	//})
44 46
 	//
45
-	specszbllis := "0 0 4 * * ?" // 每天凌晨4点00同步 深圳百霖
46
-	createLisSyncCronJob.AddFunc(specszbllis, func() {
47
-		SyncSZblLis()
48
-	})
47
+	// specszbllis := "0 0 4 * * ?" // 每天凌晨4点00同步 深圳百霖
48
+	// createLisSyncCronJob.AddFunc(specszbllis, func() {
49
+	// 	SyncSZblLis()
50
+	// })
49 51
 
50
-	specszbllisResult := "0 30 4 * * ?" // 每天凌晨4点30同步 深圳百霖
51
-	createLisSyncCronJob.AddFunc(specszbllisResult, func() {
52
-		SyncSZblLisResult()
53
-	})
52
+	// specszbllisResult := "0 30 4 * * ?" // 每天凌晨4点30同步 深圳百霖
53
+	// createLisSyncCronJob.AddFunc(specszbllisResult, func() {
54
+	// 	SyncSZblLisResult()
55
+	// })
56
+}
57
+
58
+// 返回一个支持至 秒 级别的 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())
54 63
 }
55 64
 
56 65
 func BeginAutoSyncLis() {
66
+	utils.InfoLog("开启自动检验检查同步定时任务")
67
+	createLisSyncCronJob := newWithSeconds()
68
+	 
69
+	specgzjh := "0 */1 * * * ?" // 每1分钟同步 广州暨华HIS医嘱
70
+	createLisSyncCronJob.AddFunc(specgzjh, func() {
71
+		SyncGzjhyz()
72
+	})
73
+
74
+	specys := "0 0 3 * * ?" // 每天凌晨3点同步 湖北监利
75
+	createLisSyncCronJob.AddFunc(specys, func() {
76
+		SyncHbdyLis()
77
+	})
78
+
79
+	// spec := "0 0 1 * * ?" // 每天凌晨1点同步 中能建的
80
+	// createLisSyncCronJob.AddFunc(spec, func() {
81
+	// 	AutoSyncLis()
82
+	// })
57 83
 	createLisSyncCronJob.Start()
58 84
 }
59 85
 
@@ -198,14 +224,14 @@ func SyncToBase() {
198 224
 	utils.SuccessLog("检验检查同步任务完成")
199 225
 }
200 226
 
201
-func SyncSZblLis() {
202
-	utils.TraceLog("检验检查同步任务开始执行")
203
-	org_id := int64(10138)
204
-	GetDataInsertDB(org_id)
205
-}
206
-
207
-func SyncSZblLisResult() {
208
-	utils.TraceLog("获取检验检查结果任务开始执行")
209
-	org_id := int64(10138)
210
-	GetResultDataInsertDB(org_id)
211
-}
227
+// func SyncSZblLis() {
228
+// 	utils.TraceLog("检验检查同步任务开始执行")
229
+// 	org_id := int64(10138)
230
+// 	GetDataInsertDB(org_id)
231
+// }
232
+
233
+// func SyncSZblLisResult() {
234
+// 	utils.TraceLog("获取检验检查结果任务开始执行")
235
+// 	org_id := int64(10138)
236
+// 	GetResultDataInsertDB(org_id)
237
+// }

+ 36 - 20
service/db.go View File

@@ -27,6 +27,7 @@ import (
27 27
 
28 28
 var readDb *gorm.DB
29 29
 var writeDb *gorm.DB
30
+var tempwriteDb *gorm.DB
30 31
 var readRemoteDb *gorm.DB
31 32
 var writeUserDb *gorm.DB
32 33
 var readUserDb *gorm.DB
@@ -52,6 +53,12 @@ func ConnectDB() {
52 53
 	writePass := beego.AppConfig.String("writemysqlpass")
53 54
 	writeName := beego.AppConfig.String("writemysqlname")
54 55
 
56
+	tempwriteHost := beego.AppConfig.String("tempwritemysqlhost")
57
+	tempwritePort := beego.AppConfig.String("tempwritemysqlport")
58
+	tempwriteUser := beego.AppConfig.String("tempwritemysqluser")
59
+	tempwritePass := beego.AppConfig.String("tempwritemysqlpass")
60
+	tempwriteName := beego.AppConfig.String("tempwritemysqlname")
61
+
55 62
 	readUserHost := beego.AppConfig.String("readuserhost")
56 63
 	readUserPort := beego.AppConfig.String("readuserport")
57 64
 	readUserUser := beego.AppConfig.String("readuseruser")
@@ -88,20 +95,21 @@ func ConnectDB() {
88 95
 	// backupPass := beego.AppConfig.String("backuppass")
89 96
 	// backupName := beego.AppConfig.String("backupname")
90 97
 
91
-	blHost := beego.AppConfig.String("blmysqlhost")
92
-	blPort := beego.AppConfig.String("blmysqlport")
93
-	blUser := beego.AppConfig.String("blmysqluser")
94
-	blPass := beego.AppConfig.String("blmysqlpass")
95
-	blName := beego.AppConfig.String("blmysqlname")
98
+	// blHost := beego.AppConfig.String("blmysqlhost")
99
+	// blPort := beego.AppConfig.String("blmysqlport")
100
+	// blUser := beego.AppConfig.String("blmysqluser")
101
+	// blPass := beego.AppConfig.String("blmysqlpass")
102
+	// blName := beego.AppConfig.String("blmysqlname")
96 103
 
97
-	fmt.Println(blHost)
98
-	fmt.Println(blPort)
99
-	fmt.Println(blUser)
100
-	fmt.Println(blPass)
101
-	fmt.Println(blName)
104
+	// fmt.Println(blHost)
105
+	// fmt.Println(blPort)
106
+	// fmt.Println(blUser)
107
+	// fmt.Println(blPass)
108
+	// fmt.Println(blName)
102 109
 
103 110
 	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
104 111
 	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
112
+	tempwdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", tempwriteUser, tempwritePass, tempwriteHost, tempwritePort, tempwriteName)
105 113
 
106 114
 	// rudsn := fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s", readRemoteHost, readRemotePort, readRemoteName, readRemoteUser, readRemotePass)
107 115
 	wudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUser, writeUserPass, writeUserHost, writeUserPort, writeUserName)
@@ -110,7 +118,7 @@ func ConnectDB() {
110 118
 	wmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeMiddleUser, writeMiddlePass, writeMiddleHost, writeMiddlePort, writeMiddleName)
111 119
 	rudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUser, readUserPass, readUserHost, readUserPort, readUserName)
112 120
 
113
-	bldsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", blUser, blPass, blHost, blPort, blName)
121
+	// bldsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", blUser, blPass, blHost, blPort, blName)
114 122
 
115 123
 	// bdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", backupUser, backupPass, backupHost, backupPort, backupName)
116 124
 
@@ -138,6 +146,14 @@ func ConnectDB() {
138 146
 	writeDb.DB().SetMaxOpenConns(100)
139 147
 	writeDb.LogMode(true)
140 148
 
149
+	tempwriteDb, err = gorm.Open("mysql", tempwdsn)
150
+	if err != nil {
151
+		//beego.Error(err)
152
+	}
153
+	tempwriteDb.DB().SetMaxIdleConns(10)
154
+	tempwriteDb.DB().SetMaxOpenConns(100)
155
+	tempwriteDb.LogMode(true)
156
+
141 157
 	// fmt.Println(rudsn)
142 158
 
143 159
 	// readRemoteDb, err = gorm.Open("mssql", rudsn)
@@ -180,16 +196,16 @@ func ConnectDB() {
180 196
 	readUserDb.DB().SetMaxOpenConns(100)
181 197
 	readUserDb.LogMode(true)
182 198
 
183
-	blDb, err = gorm.Open("mysql", bldsn)
184
-	if err != nil {
185
-		fmt.Println("12344")
186
-		fmt.Println(bldsn)
199
+	// blDb, err = gorm.Open("mysql", bldsn)
200
+	// if err != nil {
201
+	// 	fmt.Println("12344")
202
+	// 	fmt.Println(bldsn)
187 203
 
188
-		fmt.Println(err)
189
-	}
190
-	blDb.DB().SetMaxIdleConns(10)
191
-	blDb.DB().SetMaxOpenConns(100)
192
-	blDb.LogMode(true)
204
+	// 	fmt.Println(err)
205
+	// }
206
+	// blDb.DB().SetMaxIdleConns(10)
207
+	// blDb.DB().SetMaxOpenConns(100)
208
+	// blDb.LogMode(true)
193 209
 
194 210
 }
195 211
 

+ 11 - 0
service/lis_service.go View File

@@ -17,6 +17,17 @@ func GetAllAdvice() (Advice []models.DoctorAdvice,err error) {
17 17
 	return
18 18
 }
19 19
 
20
+// 获取备份库所有的医嘱信息
21
+func GetScheduless(id int64) (schedule models.Schedules,err error) {
22
+	err = tempwriteDb.Model(&models.Schedules{}).Where("id = ?",id).First(&schedule).Error
23
+	return
24
+}
25
+
26
+func UpdateSchedule(id int64,status int64) error{
27
+	err := writeDb.Model(&models.Schedules{}).Where("id = ? ", id).Updates(map[string]interface{}{"status":status}).Error
28
+	return err
29
+}
30
+
20 31
 // 修改医嘱信息
21 32
 func SyncAdvice(Advice *models.DoctorAdvice) error {
22 33
 	err := writeDb.Model(&models.DoctorAdvice{}).Updates(&Advice).Error

+ 1 - 1
service/redis.go View File

@@ -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().Result()
17
+	pong, err := client.Ping(client.Context()).Result()
18 18
 	fmt.Println(pong, err)
19 19
 	return client
20 20
 }

+ 42 - 27
service/ystx_service.go View File

@@ -494,12 +494,14 @@ type gzjhyz struct {
494 494
 	UTime                 string `json:"u_time"`
495 495
 }
496 496
 
497
-func GetGzjhYz(sync_time string, his_user_id string) (str gzjhResult, checkStr string) {
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
-	rep := httplib.Post(apiurl)
500
-	rep.Param("sync_time", sync_time)
501
-	rep.Param("access_token", "")
499
+	rep := httplib.Get(apiurl)
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))
504
+	utils.InfoLog(his_user_id)
503 505
 	// str, _ := rep.String()
504 506
 	xmlKey := XmlKey{}
505 507
 	rep.ToXML(&xmlKey)
@@ -522,38 +524,41 @@ func GetAdviceBySyncAdviceId(orgId int64, sync_advice_id int64) (advice models.X
522 524
 // 广州暨华透析中心医嘱同步
523 525
 func SyncGzjhyz() (err error) {
524 526
 	// 第一步:获取上次同步时间
525
-	org_id := int64(10016)
527
+	org_id := int64(10015)
526 528
 
527 529
 	redisClient := RedisClient()
528 530
 	defer redisClient.Close()
529
-	sync_time, _ := redisClient.Get("gdjh_sync_time").Result()
530
-	if len(sync_time) == 0 {
531
-		sync_time = time.Now().Format("2006010215:04:05")
531
+	sync_time_tt, _ := redisClient.Get(redisClient.Context(),"gdjh_sync_time").Result()
532
+
533
+	sync_time,_ := strconv.ParseInt(sync_time_tt,10,64)
534
+	if sync_time == 0 {
535
+		sync_time = time.Now().Unix()
532 536
 	}
533
-	new_sync_time := time.Now().Format("2006010215:04:05")
537
+	new_sync_time := time.Now().Unix()
534 538
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
535 539
 	// 切换为当前时间
536
-	redisClient.Set("gdjh_sync_time", new_sync_time, time.Minute*60*24)
540
+	redisClient.Set(redisClient.Context(),"gdjh_sync_time", new_sync_time, time.Minute*60*24)
537 541
 	// 第二步: 获取当天排班患者的住院号
538 542
 	schedulesDateStr := time.Now().Format("2006-01-02")
539 543
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
540 544
 	schedulesTime := schedulesDate.Unix()
541
-	patient_zy_ids, _ := redisClient.Get("gdjh_patient_zy_ids").Result()
542
-	if len(patient_zy_ids) == 0 {
545
+	var patient_zy_ids string
546
+	// patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
547
+	// if len(patient_zy_ids) == 0 {
543 548
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
544 549
 		if len(schedules) > 0 {
545 550
 			for _, item := range schedules {
546
-				if len(item.Patients.AdmissionNumber) > 0 {
551
+				// if len(item.Patients.AdmissionNumber) > 0 {
547 552
 					if len(patient_zy_ids) == 0 {
548
-						patient_zy_ids = item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
553
+						patient_zy_ids = item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
549 554
 					} else {
550
-						patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
555
+						patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10) + "-" + item.Patients.AdmissionNumber
551 556
 					}
552
-				}
557
+				// }
553 558
 			}
554
-			redisClient.Set("gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
559
+			// redisClient.Set(redisClient.Context(),"gdjh_patient_zy_ids", patient_zy_ids, time.Minute*5)
555 560
 		}
556
-	}
561
+	// }
557 562
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
558 563
 
559 564
 	// 第三步: 根据获取的同步时间,同步人员,去获取医嘱信息
@@ -562,7 +567,12 @@ func SyncGzjhyz() (err error) {
562 567
 		temp_id := strings.Split(idStr, "-")
563 568
 		id := temp_id[0]
564 569
 		patient_id := temp_id[1]
570
+		admission_number := temp_id[2]
565 571
 		gzjhyz, yzstr := GetGzjhYz(sync_time, id)
572
+		if len(gzjhyz.Result) == 0 && len(admission_number) > 0{
573
+			utils.InfoLog("admission_number:%v", admission_number)
574
+			gzjhyz, yzstr = GetGzjhYz(sync_time, admission_number)
575
+		}
566 576
 		utils.InfoLog("sync_time:%v", sync_time)
567 577
 		utils.InfoLog("yzstr:%v", yzstr)
568 578
 		if len(gzjhyz.Result) > 0 {
@@ -571,12 +581,12 @@ func SyncGzjhyz() (err error) {
571 581
 			for _, yz := range gzjhyz.Result {
572 582
 				// 根据姓名获取医生ID
573 583
 				var doctor_id int64
574
-				temp_doctor_id, _ := redisClient.Get("gdjh_doctor_id_" + yz.DoctorId).Result()
584
+				temp_doctor_id, _ := redisClient.Get(redisClient.Context(),"gdjh_doctor_id_" + yz.DoctorId).Result()
575 585
 				if len(temp_doctor_id) == 0 {
576 586
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorId)
577 587
 					doctor_id = doctor.AdminUserId
578 588
 					if doctor_id > 0 {
579
-						redisClient.Set("gdjh_doctor_id_"+yz.DoctorId, doctor_id, time.Minute*60*2)
589
+						redisClient.Set(redisClient.Context(),"gdjh_doctor_id_"+yz.DoctorId, doctor_id, time.Minute*60*2)
580 590
 					} else {
581 591
 						continue
582 592
 					}
@@ -616,6 +626,11 @@ func SyncGzjhyz() (err error) {
616 626
 				advice_info, _ := GetAdviceBySyncAdviceId(org_id, yz.AdviceId)
617 627
 				utils.InfoLog("advice_info:%v", advice_info)
618 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"
630
+					//清空key 值
631
+					redisClient.Set(redisClient.Context(),key, "", time.Second)
632
+					keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedulesTime, 10) + ":advice_list_all"
633
+					redisClient.Set(redisClient.Context(),keyOne, "", time.Second)
619 634
 					continue
620 635
 				} else {
621 636
 					if len(yz.AdviceName) > 0 {
@@ -903,7 +918,7 @@ func SyncHbJldyyz() (err error) {
903 918
 
904 919
 	redisClient := RedisClient()
905 920
 	defer redisClient.Close()
906
-	sync_time, _ := redisClient.Get("gdjh_sync_time1").Result()
921
+	sync_time, _ := redisClient.Get(redisClient.Context(),"gdjh_sync_time1").Result()
907 922
 	if len(sync_time) == 0 {
908 923
 		sync_time = strconv.FormatInt(time.Now().Unix(), 10)
909 924
 		utils.InfoLog("sync_time:%v", sync_time)
@@ -914,12 +929,12 @@ func SyncHbJldyyz() (err error) {
914 929
 	new_sync_time := time.Now().Unix()
915 930
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
916 931
 	// 切换为当前时间
917
-	redisClient.Set("gdjh_sync_time", new_sync_time, time.Minute*60*24)
932
+	redisClient.Set(redisClient.Context(),"gdjh_sync_time", new_sync_time, time.Minute*60*24)
918 933
 	// 第二步: 获取当天排班患者的住院号
919 934
 	schedulesDateStr := time.Now().Format("2006-01-02")
920 935
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
921 936
 	schedulesTime := schedulesDate.Unix()
922
-	patient_zy_ids, _ := redisClient.Get("gdjh_patient_zy_ids").Result()
937
+	patient_zy_ids, _ := redisClient.Get(redisClient.Context(),"gdjh_patient_zy_ids").Result()
923 938
 	if len(patient_zy_ids) == 0 {
924 939
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
925 940
 		if len(schedules) > 0 {
@@ -930,7 +945,7 @@ func SyncHbJldyyz() (err error) {
930 945
 					patient_zy_ids = patient_zy_ids + "," + item.Patients.IdCardNo + "-" + strconv.FormatInt(item.Patients.ID, 10)
931 946
 				}
932 947
 			}
933
-			redisClient.Set("gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
948
+			redisClient.Set(redisClient.Context(),"gdjh_patient_zy_ids", patient_zy_ids, time.Minute*60*2)
934 949
 		}
935 950
 	}
936 951
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
@@ -947,12 +962,12 @@ func SyncHbJldyyz() (err error) {
947 962
 				utils.InfoLog("yz:%v", yz)
948 963
 				// 根据姓名获取医生ID
949 964
 				var doctor_id int64
950
-				temp_doctor_id, _ := redisClient.Get("gdjh_doctor_id_" + strconv.FormatInt(yz.DoctorId, 10)).Result()
965
+				temp_doctor_id, _ := redisClient.Get(redisClient.Context(),"gdjh_doctor_id_" + strconv.FormatInt(yz.DoctorId, 10)).Result()
951 966
 				if len(temp_doctor_id) == 0 {
952 967
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorName)
953 968
 					doctor_id = doctor.AdminUserId
954 969
 					if doctor_id > 0 {
955
-						redisClient.Set("gdjh_doctor_id_"+strconv.FormatInt(yz.DoctorId, 10), doctor_id, time.Minute*60*2)
970
+						redisClient.Set(redisClient.Context(),"gdjh_doctor_id_"+strconv.FormatInt(yz.DoctorId, 10), doctor_id, time.Minute*60*2)
956 971
 					} else {
957 972
 						continue
958 973
 					}
@@ -1051,7 +1066,7 @@ func GethbdyLis(sync_time string, his_user_id string) (str hbdyLisResult, checkS
1051 1066
 	return checkJSON, strs
1052 1067
 }
1053 1068
 
1054
-// 广州暨华透析中心Lis同步
1069
+// 湖北监利大院透析中心Lis同步
1055 1070
 func SyncHbdyLis() (err error) {
1056 1071
 	org_id := int64(10101)
1057 1072