张保健 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
 sso_domain = https://sso.kuyicloud.com
30
 sso_domain = https://sso.kuyicloud.com
31
 front_end_domain = "https://xt.kuyicloud.com/#"
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
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
40
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
49
 writemysqlpass = xhPECP2nFObR8aUK
49
 writemysqlpass = xhPECP2nFObR8aUK
50
 writemysqlname = sgj_xt
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
 readremotehost = 219.135.207.166
58
 readremotehost = 219.135.207.166
53
 readremoteport = 1433
59
 readremoteport = 1433
54
 readremoteuser = lis_xt
60
 readremoteuser = lis_xt
87
 backupname = sgj_xt
93
 backupname = sgj_xt
88
 
94
 
89
 
95
 
90
-redishost = kuyi6666.redis.rds.aliyuncs.com
96
+redishost = kuyicloud.redis.rds.aliyuncs.com
91
 redisport = 6379
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
 	"IC/service"
6
 	"IC/service"
7
 	"IC/utils"
7
 	"IC/utils"
8
 	"encoding/json"
8
 	"encoding/json"
9
-	_ "fmt"
9
+	"fmt"
10
 	_ "github.com/astaxie/beego"
10
 	_ "github.com/astaxie/beego"
11
 	_ "github.com/jinzhu/gorm"
11
 	_ "github.com/jinzhu/gorm"
12
 	_ "strconv"
12
 	_ "strconv"
18
 	BaseAPIController
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
 func (c *LisController) SyncAdvice() {
38
 func (c *LisController) SyncAdvice() {
22
 	// 获取备份库里所有的医嘱信息
39
 	// 获取备份库里所有的医嘱信息
23
 	advices, _ := service.GetAllAdvice()
40
 	advices, _ := service.GetAllAdvice()

+ 1 - 1
main.go View File

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

+ 20 - 0
models/lis_model.go View File

53
 	return "xt_doctor_advice"
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
 type FiledConfig struct {
76
 type FiledConfig struct {
57
 	ID          int64  `gorm:"column:id" json:"id"`
77
 	ID          int64  `gorm:"column:id" json:"id"`
58
 	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
78
 	OrgId       int64  `gorm:"column:org_id" json:"org_id"`

+ 1 - 0
routers/router.go View File

21
 	//百霖lis
21
 	//百霖lis
22
 	beego.Router("/api/lis/bltest", &controllers.LisController{}, "get:SyncBlLis")
22
 	beego.Router("/api/lis/bltest", &controllers.LisController{}, "get:SyncBlLis")
23
 	beego.Router("/api/lis/blresulttest", &controllers.LisController{}, "get:SyncBlResultLis")
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
 )
12
 )
13
 
13
 
14
 // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
14
 // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
15
-var createLisSyncCronJob *cron.Cron
15
+// var createLisSyncCronJob *cron.Cron
16
 
16
 
17
 func init() {
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
 	//speclg := "0 0 2 * * ?" // 每天凌晨2点同步 龙岗二院
25
 	//speclg := "0 0 2 * * ?" // 每天凌晨2点同步 龙岗二院
26
 	//createLisSyncCronJob.AddFunc(speclg, func() {
26
 	//createLisSyncCronJob.AddFunc(speclg, func() {
32
 	//	SyncHbdyLis()
32
 	//	SyncHbdyLis()
33
 	//})
33
 	//})
34
 
34
 
35
-	// specgzjh := "0 */1 7-20 * *  " // 每2分钟同步 广州暨华HIS医嘱
35
+	// utils.InfoLog("3333333")
36
+	// specgzjh := "1 * * * * ?" // 每1分钟同步 广州暨华HIS医嘱
36
 	// createLisSyncCronJob.AddFunc(specgzjh, func() {
37
 	// createLisSyncCronJob.AddFunc(specgzjh, func() {
38
+	// 	utils.InfoLog("1111111111")
37
 	// 	SyncGzjhyz()
39
 	// 	SyncGzjhyz()
38
 	// })
40
 	// })
39
 
41
 
42
 	//	SyncGzjhLis()
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
 func BeginAutoSyncLis() {
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
 	createLisSyncCronJob.Start()
83
 	createLisSyncCronJob.Start()
58
 }
84
 }
59
 
85
 
198
 	utils.SuccessLog("检验检查同步任务完成")
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
 
27
 
28
 var readDb *gorm.DB
28
 var readDb *gorm.DB
29
 var writeDb *gorm.DB
29
 var writeDb *gorm.DB
30
+var tempwriteDb *gorm.DB
30
 var readRemoteDb *gorm.DB
31
 var readRemoteDb *gorm.DB
31
 var writeUserDb *gorm.DB
32
 var writeUserDb *gorm.DB
32
 var readUserDb *gorm.DB
33
 var readUserDb *gorm.DB
52
 	writePass := beego.AppConfig.String("writemysqlpass")
53
 	writePass := beego.AppConfig.String("writemysqlpass")
53
 	writeName := beego.AppConfig.String("writemysqlname")
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
 	readUserHost := beego.AppConfig.String("readuserhost")
62
 	readUserHost := beego.AppConfig.String("readuserhost")
56
 	readUserPort := beego.AppConfig.String("readuserport")
63
 	readUserPort := beego.AppConfig.String("readuserport")
57
 	readUserUser := beego.AppConfig.String("readuseruser")
64
 	readUserUser := beego.AppConfig.String("readuseruser")
88
 	// backupPass := beego.AppConfig.String("backuppass")
95
 	// backupPass := beego.AppConfig.String("backuppass")
89
 	// backupName := beego.AppConfig.String("backupname")
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
 	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
110
 	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
104
 	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
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
 	// rudsn := fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s", readRemoteHost, readRemotePort, readRemoteName, readRemoteUser, readRemotePass)
114
 	// rudsn := fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s", readRemoteHost, readRemotePort, readRemoteName, readRemoteUser, readRemotePass)
107
 	wudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUser, writeUserPass, writeUserHost, writeUserPort, writeUserName)
115
 	wudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUser, writeUserPass, writeUserHost, writeUserPort, writeUserName)
110
 	wmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeMiddleUser, writeMiddlePass, writeMiddleHost, writeMiddlePort, writeMiddleName)
118
 	wmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeMiddleUser, writeMiddlePass, writeMiddleHost, writeMiddlePort, writeMiddleName)
111
 	rudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUser, readUserPass, readUserHost, readUserPort, readUserName)
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
 	// bdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", backupUser, backupPass, backupHost, backupPort, backupName)
123
 	// bdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", backupUser, backupPass, backupHost, backupPort, backupName)
116
 
124
 
138
 	writeDb.DB().SetMaxOpenConns(100)
146
 	writeDb.DB().SetMaxOpenConns(100)
139
 	writeDb.LogMode(true)
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
 	// fmt.Println(rudsn)
157
 	// fmt.Println(rudsn)
142
 
158
 
143
 	// readRemoteDb, err = gorm.Open("mssql", rudsn)
159
 	// readRemoteDb, err = gorm.Open("mssql", rudsn)
180
 	readUserDb.DB().SetMaxOpenConns(100)
196
 	readUserDb.DB().SetMaxOpenConns(100)
181
 	readUserDb.LogMode(true)
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
 	return
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
 func SyncAdvice(Advice *models.DoctorAdvice) error {
32
 func SyncAdvice(Advice *models.DoctorAdvice) error {
22
 	err := writeDb.Model(&models.DoctorAdvice{}).Updates(&Advice).Error
33
 	err := writeDb.Model(&models.DoctorAdvice{}).Updates(&Advice).Error

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

+ 42 - 27
service/ystx_service.go View File

494
 	UTime                 string `json:"u_time"`
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
 	apiurl := "http://219.135.166.106:8067/WebService.asmx/queryyzxx"
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
 	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))
504
+	utils.InfoLog(his_user_id)
503
 	// str, _ := rep.String()
505
 	// str, _ := rep.String()
504
 	xmlKey := XmlKey{}
506
 	xmlKey := XmlKey{}
505
 	rep.ToXML(&xmlKey)
507
 	rep.ToXML(&xmlKey)
522
 // 广州暨华透析中心医嘱同步
524
 // 广州暨华透析中心医嘱同步
523
 func SyncGzjhyz() (err error) {
525
 func SyncGzjhyz() (err error) {
524
 	// 第一步:获取上次同步时间
526
 	// 第一步:获取上次同步时间
525
-	org_id := int64(10016)
527
+	org_id := int64(10015)
526
 
528
 
527
 	redisClient := RedisClient()
529
 	redisClient := RedisClient()
528
 	defer redisClient.Close()
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
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
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
 	schedulesDateStr := time.Now().Format("2006-01-02")
542
 	schedulesDateStr := time.Now().Format("2006-01-02")
539
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
543
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
540
 	schedulesTime := schedulesDate.Unix()
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
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
548
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
544
 		if len(schedules) > 0 {
549
 		if len(schedules) > 0 {
545
 			for _, item := range schedules {
550
 			for _, item := range schedules {
546
-				if len(item.Patients.AdmissionNumber) > 0 {
551
+				// if len(item.Patients.AdmissionNumber) > 0 {
547
 					if len(patient_zy_ids) == 0 {
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
 					} else {
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
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
562
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
558
 
563
 
559
 	// 第三步: 根据获取的同步时间,同步人员,去获取医嘱信息
564
 	// 第三步: 根据获取的同步时间,同步人员,去获取医嘱信息
562
 		temp_id := strings.Split(idStr, "-")
567
 		temp_id := strings.Split(idStr, "-")
563
 		id := temp_id[0]
568
 		id := temp_id[0]
564
 		patient_id := temp_id[1]
569
 		patient_id := temp_id[1]
570
+		admission_number := temp_id[2]
565
 		gzjhyz, yzstr := GetGzjhYz(sync_time, id)
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
 		utils.InfoLog("sync_time:%v", sync_time)
576
 		utils.InfoLog("sync_time:%v", sync_time)
567
 		utils.InfoLog("yzstr:%v", yzstr)
577
 		utils.InfoLog("yzstr:%v", yzstr)
568
 		if len(gzjhyz.Result) > 0 {
578
 		if len(gzjhyz.Result) > 0 {
571
 			for _, yz := range gzjhyz.Result {
581
 			for _, yz := range gzjhyz.Result {
572
 				// 根据姓名获取医生ID
582
 				// 根据姓名获取医生ID
573
 				var doctor_id int64
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
 				if len(temp_doctor_id) == 0 {
585
 				if len(temp_doctor_id) == 0 {
576
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorId)
586
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorId)
577
 					doctor_id = doctor.AdminUserId
587
 					doctor_id = doctor.AdminUserId
578
 					if doctor_id > 0 {
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
 					} else {
590
 					} else {
581
 						continue
591
 						continue
582
 					}
592
 					}
616
 				advice_info, _ := GetAdviceBySyncAdviceId(org_id, yz.AdviceId)
626
 				advice_info, _ := GetAdviceBySyncAdviceId(org_id, yz.AdviceId)
617
 				utils.InfoLog("advice_info:%v", advice_info)
627
 				utils.InfoLog("advice_info:%v", advice_info)
618
 				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"
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
 					continue
634
 					continue
620
 				} else {
635
 				} else {
621
 					if len(yz.AdviceName) > 0 {
636
 					if len(yz.AdviceName) > 0 {
903
 
918
 
904
 	redisClient := RedisClient()
919
 	redisClient := RedisClient()
905
 	defer redisClient.Close()
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
 	if len(sync_time) == 0 {
922
 	if len(sync_time) == 0 {
908
 		sync_time = strconv.FormatInt(time.Now().Unix(), 10)
923
 		sync_time = strconv.FormatInt(time.Now().Unix(), 10)
909
 		utils.InfoLog("sync_time:%v", sync_time)
924
 		utils.InfoLog("sync_time:%v", sync_time)
914
 	new_sync_time := time.Now().Unix()
929
 	new_sync_time := time.Now().Unix()
915
 	utils.InfoLog("new_sync_time:%v", new_sync_time)
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
 	schedulesDateStr := time.Now().Format("2006-01-02")
934
 	schedulesDateStr := time.Now().Format("2006-01-02")
920
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
935
 	schedulesDate, _ := utils.ParseTimeStringToTime("2006-01-02", schedulesDateStr)
921
 	schedulesTime := schedulesDate.Unix()
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
 	if len(patient_zy_ids) == 0 {
938
 	if len(patient_zy_ids) == 0 {
924
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
939
 		schedules, _ := GetPatientGzjhList(org_id, schedulesTime)
925
 		if len(schedules) > 0 {
940
 		if len(schedules) > 0 {
930
 					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)
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
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
951
 	utils.InfoLog("2gdjh_patient_zy_ids:%v", patient_zy_ids)
947
 				utils.InfoLog("yz:%v", yz)
962
 				utils.InfoLog("yz:%v", yz)
948
 				// 根据姓名获取医生ID
963
 				// 根据姓名获取医生ID
949
 				var doctor_id int64
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
 				if len(temp_doctor_id) == 0 {
966
 				if len(temp_doctor_id) == 0 {
952
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorName)
967
 					doctor, _ := GetAdminUserId(org_id, yz.DoctorName)
953
 					doctor_id = doctor.AdminUserId
968
 					doctor_id = doctor.AdminUserId
954
 					if doctor_id > 0 {
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
 					} else {
971
 					} else {
957
 						continue
972
 						continue
958
 					}
973
 					}
1051
 	return checkJSON, strs
1066
 	return checkJSON, strs
1052
 }
1067
 }
1053
 
1068
 
1054
-// 广州暨华透析中心Lis同步
1069
+// 湖北监利大院透析中心Lis同步
1055
 func SyncHbdyLis() (err error) {
1070
 func SyncHbdyLis() (err error) {
1056
 	org_id := int64(10101)
1071
 	org_id := int64(10101)
1057
 
1072