张保健 7 months ago
parent
commit
95e93b3fba
12 changed files with 426 additions and 127 deletions
  1. 16 16
      conf/app.conf
  2. 53 37
      controllers/lis.go
  3. 5 2
      main.go
  4. 6 4
      models/lis_model.go
  5. 34 32
      routers/router.go
  6. 11 1
      service/cron.go
  7. 234 3
      service/csny_service.go
  8. 22 22
      service/db.go
  9. 2 2
      service/pajm_service.go
  10. 4 0
      service/sgyhs_service.go
  11. 34 5
      service/sssy_service.go
  12. 5 3
      service/sy_service.go

+ 16 - 16
conf/app.conf View File

37
 # blmysqlname = kuyicloud
37
 # blmysqlname = kuyicloud
38
 
38
 
39
 
39
 
40
-readmysqlhost = shengws1.mysql.rds.aliyuncs.com
40
+readmysqlhost = kuyicl.mysql.rds.aliyuncs.com
41
 readmysqlport = 3306
41
 readmysqlport = 3306
42
 readmysqluser = syh
42
 readmysqluser = syh
43
-readmysqlpass = xhPECP2nFObR8aUK
43
+readmysqlpass = yHXAcb7dTJyv
44
 readmysqlname = sgj_xt
44
 readmysqlname = sgj_xt
45
 
45
 
46
-writemysqlhost = shengws1.mysql.rds.aliyuncs.com
46
+writemysqlhost = kuyicl.mysql.rds.aliyuncs.com
47
 writemysqlport = 3306
47
 writemysqlport = 3306
48
 writemysqluser = syh
48
 writemysqluser = syh
49
-writemysqlpass = xhPECP2nFObR8aUK
49
+writemysqlpass = yHXAcb7dTJyv
50
 writemysqlname = sgj_xt
50
 writemysqlname = sgj_xt
51
 
51
 
52
-tempwritemysqlhost = rm-wz930n4u3k76i95tuuo.mysql.rds.aliyuncs.com
52
+tempwritemysqlhost = kuyicl.mysql.rds.aliyuncs.com
53
 tempwritemysqlport = 3306
53
 tempwritemysqlport = 3306
54
 tempwritemysqluser = syh
54
 tempwritemysqluser = syh
55
-tempwritemysqlpass = xhPECP2nFObR8aUK
55
+tempwritemysqlpass = yHXAcb7dTJyv
56
 tempwritemysqlname = sgj_xt
56
 tempwritemysqlname = sgj_xt
57
 
57
 
58
 readremotehost = 219.135.207.166
58
 readremotehost = 219.135.207.166
62
 readremotename = digitlab
62
 readremotename = digitlab
63
 
63
 
64
 
64
 
65
-readuserhost = shengws1.mysql.rds.aliyuncs.com
65
+readuserhost = kuyicl.mysql.rds.aliyuncs.com
66
 readuserport = 3306
66
 readuserport = 3306
67
 readuseruser = syh
67
 readuseruser = syh
68
-readuserpass = xhPECP2nFObR8aUK
68
+readuserpass = yHXAcb7dTJyv
69
 readusername = sgj_users
69
 readusername = sgj_users
70
 
70
 
71
-writeuserhost = shengws1.mysql.rds.aliyuncs.com
71
+writeuserhost = kuyicl.mysql.rds.aliyuncs.com
72
 writeuserport = 3306
72
 writeuserport = 3306
73
 writeuseruser = syh
73
 writeuseruser = syh
74
-writeuserpass = xhPECP2nFObR8aUK
74
+writeuserpass = yHXAcb7dTJyv
75
 writeusername = sgj_users
75
 writeusername = sgj_users
76
 
76
 
77
-readmiddlehost = shengws1.mysql.rds.aliyuncs.com
77
+readmiddlehost = kuyicl.mysql.rds.aliyuncs.com
78
 readmiddleport = 3306
78
 readmiddleport = 3306
79
 readmiddleuser = syh
79
 readmiddleuser = syh
80
-readmiddlepass = xhPECP2nFObR8aUK
80
+readmiddlepass = yHXAcb7dTJyv
81
 readmiddlename = ky_xt_middle
81
 readmiddlename = ky_xt_middle
82
 
82
 
83
-writemiddlehost = shengws1.mysql.rds.aliyuncs.com
83
+writemiddlehost = kuyicl.mysql.rds.aliyuncs.com
84
 writemiddleport = 3306
84
 writemiddleport = 3306
85
 writemiddleuser = syh
85
 writemiddleuser = syh
86
-writemiddlepass = xhPECP2nFObR8aUK
86
+writemiddlepass = yHXAcb7dTJyv
87
 writemiddlename = ky_xt_middle
87
 writemiddlename = ky_xt_middle
88
 
88
 
89
 backuphost = 120.76.159.131
89
 backuphost = 120.76.159.131
90
 backupport = 3306
90
 backupport = 3306
91
-backupuser = syh
92
-backuppass = xhPECP2nFObR8aUK
91
+backupuser = kuyicloud
92
+backuppass = yHXAcb7dTJyvMiX3vK2iOvTAHeaowy5P
93
 backupname = sgj_xt
93
 backupname = sgj_xt
94
 
94
 
95
 
95
 

+ 53 - 37
controllers/lis.go View File

18
 	BaseAPIController
18
 	BaseAPIController
19
 }
19
 }
20
 
20
 
21
+func (c *LisController) SyncChydLis() {
22
+	service.SyncLisChyd(1)
23
+	c.ServeSuccessJSON(map[string]interface{}{
24
+		"resultList": "12345",
25
+	})
26
+	return
27
+}
28
+
29
+//func (c *LisController) Test() {
30
+//	service.SyncJhhjyyLis()
31
+//	c.ServeSuccessJSON(map[string]interface{}{
32
+//		"resultList": "12345",
33
+//	})
34
+//	return
35
+//}
36
+
21
 func (c *LisController) Schedule() {
37
 func (c *LisController) Schedule() {
22
 	for i := 762429; i > 0; i-- {
38
 	for i := 762429; i > 0; i-- {
23
 		schedule, err := service.GetScheduless(int64(i))
39
 		schedule, err := service.GetScheduless(int64(i))
35
 
51
 
36
 }
52
 }
37
 
53
 
38
-// 普宁锦熹血液透析中心Lis同步
39
-func (c *LisController) SyncPljx() {
40
-	service.SyncLisPljx(10599)
41
-	c.ServeSuccessJSON(map[string]interface{}{
42
-		"resultList": "12345",
43
-	})
44
-	return
45
-}
54
+//// 普宁锦熹血液透析中心Lis同步
55
+//func (c *LisController) SyncPljx() {
56
+//	service.SyncLisPljx(10599)
57
+//	c.ServeSuccessJSON(map[string]interface{}{
58
+//		"resultList": "12345",
59
+//	})
60
+//	return
61
+//}
46
 
62
 
47
 // 遵化仁爱医院Lis同步
63
 // 遵化仁爱医院Lis同步
48
-func (c *LisController) SyncZhraLis() {
49
-	service.SyncTszhraLis()
50
-	c.ServeSuccessJSON(map[string]interface{}{
51
-		"resultList": "12345",
52
-	})
53
-	return
54
-}
64
+//func (c *LisController) SyncZhraLis() {
65
+//	service.SyncTszhraLis()
66
+//	c.ServeSuccessJSON(map[string]interface{}{
67
+//		"resultList": "12345",
68
+//	})
69
+//	return
70
+//}
55
 
71
 
56
 // 北京南诚中西医结合医院Lis同步
72
 // 北京南诚中西医结合医院Lis同步
57
-func (c *LisController) SyncBjncLis() {
58
-	service.SyncBjncLis()
59
-	c.ServeSuccessJSON(map[string]interface{}{
60
-		"resultList": "12345",
61
-	})
62
-	return
63
-}
73
+//func (c *LisController) SyncBjncLis() {
74
+//	service.SyncBjncLis()
75
+//	c.ServeSuccessJSON(map[string]interface{}{
76
+//		"resultList": "12345",
77
+//	})
78
+//	return
79
+//}
64
 
80
 
65
 // 广州康允LIS同步
81
 // 广州康允LIS同步
66
-func (c *LisController) SyncGzky() {
67
-	service.SyncGzkyLis()
68
-	c.ServeSuccessJSON(map[string]interface{}{
69
-		"resultList": "12345",
70
-	})
71
-	return
72
-}
73
-
74
-func (c *LisController) SyncSzwz() {
75
-	service.SyncLisSzwz()
76
-	c.ServeSuccessJSON(map[string]interface{}{
77
-		"resultList": "12345",
78
-	})
79
-	return
80
-}
82
+//func (c *LisController) SyncGzky() {
83
+//	service.SyncGzkyLis()
84
+//	c.ServeSuccessJSON(map[string]interface{}{
85
+//		"resultList": "12345",
86
+//	})
87
+//	return
88
+//}
89
+
90
+//func (c *LisController) SyncSzwz() {
91
+//	service.SyncLisSzwz()
92
+//	c.ServeSuccessJSON(map[string]interface{}{
93
+//		"resultList": "12345",
94
+//	})
95
+//	return
96
+//}
81
 
97
 
82
 // 石狮盛誉LIS同步
98
 // 石狮盛誉LIS同步
83
 func (c *LisController) SyncSssy() {
99
 func (c *LisController) SyncSssy() {

+ 5 - 2
main.go View File

18
 	service.BeginAutoSyncLis()
18
 	service.BeginAutoSyncLis()
19
 	//service.SyncStsyLis() //  汕头三优  打开程序马上运行LIS同步
19
 	//service.SyncStsyLis() //  汕头三优  打开程序马上运行LIS同步
20
 	//service.SyncLisSgyhs() //  韶关源和盛  打开程序马上运行LIS同步
20
 	//service.SyncLisSgyhs() //  韶关源和盛  打开程序马上运行LIS同步
21
-	//service.SyncLisPljx(10599) //  揭阳景熹透析中心  打开程序马上运行LIS同步
22
-	service.SyncTszhraLis() // 遵化仁爱医院  打开程序马上运行LIS同步
21
+	//service.SyncCsnyLis() //  揭阳景熹透析中心  打开程序马上运行LIS同步
22
+	//service.SyncTszhraLis() // 遵化仁爱医院  打开程序马上运行LIS同步
23
+	//service.SyncLisYstxChyd() // 从化意达透析中心  打开程序马上运行LIS同步
24
+	//service.SyncJhhjyyLis() // 湖南郴州嘉禾恒佳医院  打开程序马上运行LIS同步
25
+	//service.SyncSYData2() // 石狮盛誉血液透析中心  打开程序马上运行LIS同步
23
 	beego.Run()
26
 	beego.Run()
24
 }
27
 }

+ 6 - 4
models/lis_model.go View File

412
 	UTime        string `gorm:"column:u_time" json:"u_time" form:"u_time"`
412
 	UTime        string `gorm:"column:u_time" json:"u_time" form:"u_time"`
413
 	IsSync       int    `gorm:"column:is_sync" json:"is_sync" form:"is_sync"`
413
 	IsSync       int    `gorm:"column:is_sync" json:"is_sync" form:"is_sync"`
414
 	// SyncItemId int64 `gorm:"column:sync_item_id" json:"sync_item_id" form:"sync_item_id"`
414
 	// SyncItemId int64 `gorm:"column:sync_item_id" json:"sync_item_id" form:"sync_item_id"`
415
-	HisUserId    string `gorm:"column:his_user_id" json:"his_user_id" form:"his_user_id"`
416
-	SyncId       int64  `gorm:"column:sync_id" json:"sync_id" form:"sync_id"`
417
-	SysProjectId int64  `gorm:"column:sys_project_id" json:"sys_project_id" form:"sys_project_id"`
418
-	SysItemId    int64  `gorm:"column:sys_item_id" json:"sys_item_id" form:"sys_item_id"`
415
+	HisUserId     string `gorm:"column:his_user_id" json:"his_user_id" form:"his_user_id"`
416
+	SyncId        int64  `gorm:"column:sync_id" json:"sync_id" form:"sync_id"`
417
+	SysProjectId  int64  `gorm:"column:sys_project_id" json:"sys_project_id" form:"sys_project_id"`
418
+	SysItemId     int64  `gorm:"column:sys_item_id" json:"sys_item_id" form:"sys_item_id"`
419
+	Adiconbarcode string `gorm:"column:adiconbarcode" json:"adiconbarcode" form:"adiconbarcode"`
419
 }
420
 }
420
 
421
 
421
 func (MiddleInspection) TableName() string {
422
 func (MiddleInspection) TableName() string {
448
 	ItemCode         string `gorm:"column:item_code" json:"item_code" form:"item_code"`
449
 	ItemCode         string `gorm:"column:item_code" json:"item_code" form:"item_code"`
449
 	XtProjectId      int64  `gorm:"column:xt_project_id" json:"xt_project_id" form:"xt_project_id"`
450
 	XtProjectId      int64  `gorm:"column:xt_project_id" json:"xt_project_id" form:"xt_project_id"`
450
 	XtItemId         int64  `gorm:"column:xt_item_id" json:"xt_item_id" form:"xt_item_id"`
451
 	XtItemId         int64  `gorm:"column:xt_item_id" json:"xt_item_id" form:"xt_item_id"`
452
+	Adiconbarcode    string `gorm:"column:adiconbarcode" json:"adiconbarcode" form:"adiconbarcode"`
451
 }
453
 }
452
 
454
 
453
 func (MiddleInspectionReference) TableName() string {
455
 func (MiddleInspectionReference) TableName() string {

+ 34 - 32
routers/router.go View File

7
 
7
 
8
 func init() {
8
 func init() {
9
 	beego.Router("/", &controllers.MainController{})
9
 	beego.Router("/", &controllers.MainController{})
10
-	beego.Router("/api/lis/getlist", &controllers.LisController{}, "get:GetList")
11
-	beego.Router("/api/lis/synctobase", &controllers.LisController{}, "get:SyncToBase")
12
-	beego.Router("/api/lis/synfiled", &controllers.LisController{}, "get:FiledConfigSys")
13
-	beego.Router("/api/lis/syncadvice", &controllers.LisController{}, "get:SyncAdvice")
14
-	beego.Router("/api/lis/lgeysync", &controllers.LisController{}, "get:SyncLgth")
15
-	beego.Router("/api/lis/ystxsync", &controllers.LisController{}, "get:SyncYstx")
16
-	beego.Router("/api/lis/gzjhyzsync", &controllers.LisController{}, "get:SyncGzjhyz")
17
-	beego.Router("/api/lis/gzjhlissync", &controllers.LisController{}, "get:SyncGzjhLis")
18
-	beego.Router("/api/lis/hbdyyzsync", &controllers.LisController{}, "get:SyncHbJldyyz")
19
-	beego.Router("/api/lis/hbdylissync", &controllers.LisController{}, "get:SyncHbJldyLis")
20
-	beego.Router("/api/lis/tscylissync", &controllers.LisController{}, "get:SyncTscyLis")
21
-	beego.Router("/api/lis/fjtflissync", &controllers.LisController{}, "get:SyncFjtfLis")
22
-	beego.Router("/api/lis/csnylissync", &controllers.LisController{}, "get:SyncCsnyLis")
23
-
24
-	//百霖lis
25
-	beego.Router("/api/lis/bltest", &controllers.LisController{}, "get:SyncBlLis")
26
-	beego.Router("/api/lis/blresulttest", &controllers.LisController{}, "get:SyncBlResultLis")
27
-	beego.Router("/api/schedule", &controllers.LisController{}, "get:Schedule")
28
-
29
-	beego.Router("/api/syncshLis", &controllers.LisController{}, "get:SyncShLis")
30
-	beego.Router("/api/syncszblis", &controllers.LisController{}, "get:SyncSzblLis")
31
-	beego.Router("/api/test", &controllers.LisController{}, "get:SyncTest")
32
-	//beego.Router("/api/lis/gzjhxytx", &controllers.LisController{}, "get:SyncGzjhxytx")
33
-	//beego.Router("/api/lis/scdckfyy", &controllers.LisController{}, "get:SyncSccdkfyyLis")
34
-	//beego.Router("/api/lis/pajm", &controllers.LisController{}, "get:SyncPajmLis")
35
-	beego.Router("/api/lis/sssy", &controllers.LisController{}, "get:SyncSssy")
36
-	beego.Router("/api/lis/tscyvip", &controllers.LisController{}, "get:SyncTscyVipLis")
37
-	beego.Router("/api/lis/syncgzky", &controllers.LisController{}, "get:SyncGzky")
38
-	beego.Router("/api/lis/syncszwz", &controllers.LisController{}, "get:SyncSzwz")
39
-	beego.Router("/api/lis/syncpljx", &controllers.LisController{}, "get:SyncPljx")
40
-	beego.Router("/api/lis/syncbjnc", &controllers.LisController{}, "get:SyncBjncLis")
41
-	beego.Router("/api/lis/synczhra", &controllers.LisController{}, "get:SyncZhraLis")
10
+	//beego.Router("/api/lis/getlist", &controllers.LisController{}, "get:GetList")
11
+	//beego.Router("/api/lis/synctobase", &controllers.LisController{}, "get:SyncToBase")
12
+	//beego.Router("/api/lis/synfiled", &controllers.LisController{}, "get:FiledConfigSys")
13
+	//beego.Router("/api/lis/syncadvice", &controllers.LisController{}, "get:SyncAdvice")
14
+	//beego.Router("/api/lis/lgeysync", &controllers.LisController{}, "get:SyncLgth")
15
+	//beego.Router("/api/lis/ystxsync", &controllers.LisController{}, "get:SyncYstx")
16
+	//beego.Router("/api/lis/gzjhyzsync", &controllers.LisController{}, "get:SyncGzjhyz")
17
+	//beego.Router("/api/lis/gzjhlissync", &controllers.LisController{}, "get:SyncGzjhLis")
18
+	//beego.Router("/api/lis/hbdyyzsync", &controllers.LisController{}, "get:SyncHbJldyyz")
19
+	//beego.Router("/api/lis/hbdylissync", &controllers.LisController{}, "get:SyncHbJldyLis")
20
+	//beego.Router("/api/lis/tscylissync", &controllers.LisController{}, "get:SyncTscyLis")
21
+	//beego.Router("/api/lis/fjtflissync", &controllers.LisController{}, "get:SyncFjtfLis")
22
+	//beego.Router("/api/lis/csnylissync", &controllers.LisController{}, "get:SyncCsnyLis")
23
+	//
24
+	////百霖lis
25
+	//beego.Router("/api/lis/bltest", &controllers.LisController{}, "get:SyncBlLis")
26
+	//beego.Router("/api/lis/blresulttest", &controllers.LisController{}, "get:SyncBlResultLis")
27
+	//beego.Router("/api/schedule", &controllers.LisController{}, "get:Schedule")
28
+	//
29
+	//beego.Router("/api/syncshLis", &controllers.LisController{}, "get:SyncShLis")
30
+	//beego.Router("/api/syncszblis", &controllers.LisController{}, "get:SyncSzblLis")
31
+	//beego.Router("/api/test", &controllers.LisController{}, "get:SyncTest")
32
+	////beego.Router("/api/lis/gzjhxytx", &controllers.LisController{}, "get:SyncGzjhxytx")
33
+	////beego.Router("/api/lis/scdckfyy", &controllers.LisController{}, "get:SyncSccdkfyyLis")
34
+	////beego.Router("/api/lis/pajm", &controllers.LisController{}, "get:SyncPajmLis")
35
+	//beego.Router("/api/lis/sssy", &controllers.LisController{}, "get:SyncSssy")
36
+	//beego.Router("/api/lis/tscyvip", &controllers.LisController{}, "get:SyncTscyVipLis")
37
+	//beego.Router("/api/lis/syncgzky", &controllers.LisController{}, "get:SyncGzky")
38
+	//beego.Router("/api/lis/syncszwz", &controllers.LisController{}, "get:SyncSzwz")
39
+	//beego.Router("/api/lis/syncpljx", &controllers.LisController{}, "get:SyncPljx")
40
+	//beego.Router("/api/lis/syncbjnc", &controllers.LisController{}, "get:SyncBjncLis")
41
+	//beego.Router("/api/lis/synczhra", &controllers.LisController{}, "get:SyncZhraLis")
42
+	beego.Router("/api/lis/syncchyd", &controllers.LisController{}, "get:SyncChydLis")
43
+	//beego.Router("/test", &controllers.LisController{}, "get:Test")
42
 }
44
 }

+ 11 - 1
service/cron.go View File

36
 	//
36
 	//
37
 	//specys1 := "0 10 */2 * * ?" // 每两个小时同步长沙南雅医院
37
 	//specys1 := "0 10 */2 * * ?" // 每两个小时同步长沙南雅医院
38
 	//createLisSyncCronJob.AddFunc(specys1, func() {
38
 	//createLisSyncCronJob.AddFunc(specys1, func() {
39
-	//	SyncCsnyLis()
39
+	//SyncCsnyLis()
40
 	//})
40
 	//})
41
 	//
41
 	//
42
 	//spec := "0 50 1 * * ?" // 每天凌晨1点同步 监利大院的
42
 	//spec := "0 50 1 * * ?" // 每天凌晨1点同步 监利大院的
99
 	//	SyncLisPljx(10599)
99
 	//	SyncLisPljx(10599)
100
 	//})
100
 	//})
101
 
101
 
102
+	//spec13 := "0 10 * * * ?" // 每个小时同步一次 唐山遵化仁爱医院LIS对接,本地部署的
103
+	//createLisSyncCronJob.AddFunc(spec13, func() {
104
+	//	SyncTszhraLis()
105
+	//})
106
+
107
+	//spec14 := "0 10 2 * * ?" // 每天凌晨步一次 从化意达血液透析中心LIS对接,服务器部署
108
+	//createLisSyncCronJob.AddFunc(spec14, func() {
109
+	//	SyncLisChyd(0)
110
+	//})
111
+
102
 	createLisSyncCronJob.Start()
112
 	createLisSyncCronJob.Start()
103
 }
113
 }
104
 
114
 

+ 234 - 3
service/csny_service.go View File

12
 	_ "github.com/jinzhu/gorm"
12
 	_ "github.com/jinzhu/gorm"
13
 	"io/ioutil"
13
 	"io/ioutil"
14
 	"net/http"
14
 	"net/http"
15
+	"unicode/utf8"
15
 
16
 
16
 	"strconv"
17
 	"strconv"
17
 	"strings"
18
 	"strings"
18
 	"time"
19
 	"time"
19
 )
20
 )
20
 
21
 
22
+func lastThreeChars(s string) string {
23
+	runeCount := 0
24
+	for i := len(s); i > 0; {
25
+		_, size := utf8.DecodeLastRuneInString(s[:i])
26
+		i -= size
27
+		runeCount++
28
+		if runeCount == 3 {
29
+			return s[i:]
30
+		}
31
+	}
32
+	// 如果字符串长度少于3个字符,则返回整个字符串或空字符串
33
+	if runeCount == 0 {
34
+		return ""
35
+	}
36
+	return s
37
+}
38
+
21
 // 福建天福医院透析中心Lis同步
39
 // 福建天福医院透析中心Lis同步
22
 func SyncCsnyLis() (err error) {
40
 func SyncCsnyLis() (err error) {
23
 	org_id := int64(10340)
41
 	org_id := int64(10340)
42
+	//org_id_other := int64(103401)
24
 
43
 
25
 	// 第一步:获取上一次同步的时间点
44
 	// 第一步:获取上一次同步的时间点
26
 	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
45
 	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
31
 		sync_time = 1651334400 // 2022-05-01 00:00:00
50
 		sync_time = 1651334400 // 2022-05-01 00:00:00
32
 	}
51
 	}
33
 
52
 
53
+	//syncLastInfo1, _ := GetSyncTimeByOrgIDForYs(org_id_other)
54
+	//var sync_time_other int64
55
+	//if syncLastInfo1.ID > 0 {
56
+	//	sync_time_other = syncLastInfo1.SyncTime
57
+	//} else {
58
+	//	sync_time_other = 1651334400 // 2022-05-01 00:00:00
59
+	//}
60
+
34
 	sync_time_temp := time.Unix(sync_time, 0)
61
 	sync_time_temp := time.Unix(sync_time, 0)
35
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
62
 	syncTimeStr := sync_time_temp.Format("2006-01-02 15:04:05")
63
+
64
+	//sync_time_temp_1 := time.Unix(sync_time_other, 0)
65
+	//syncTimeStr_1 := sync_time_temp_1.Format("2006-01-02 15:04:05")
36
 	// 第二步:获取所有患者的病历号
66
 	// 第二步:获取所有患者的病历号
37
 
67
 
38
 	patientList, _ := GetPatientGzjhByOrgId(org_id)
68
 	patientList, _ := GetPatientGzjhByOrgId(org_id)
39
 	if len(patientList) > 0 {
69
 	if len(patientList) > 0 {
70
+		// 体检的检验数据
71
+		//for _, patient := range patientList {
72
+		//	if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
73
+		//		patient_id := patient.ID
74
+		//		var patient_name string
75
+		//		length := len(patient.Name)
76
+		//		if length >= 3 {
77
+		//			utils.InfoLog("名字:%v", patient.Name)
78
+		//			lastThree := lastThreeChars(patient.Name)
79
+		//			utils.InfoLog("截取后的名字:%v", lastThree)
80
+		//			re := regexp.MustCompile("[0-9]+")
81
+		//			patient_name = re.ReplaceAllString(lastThree, "")
82
+		//		} else {
83
+		//			patient_name = patient.Name
84
+		//		}
85
+		//		result, _ := CsnyGetLabTj(patient_name, syncTimeStr_1)
86
+		//		utils.InfoLog("result:%v", result)
87
+		//		var fjtfLab LabCsnyResult
88
+		//		if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
89
+		//			utils.ErrorLog("解析失败:%v", err)
90
+		//		}
91
+		//		fmt.Println(fjtfLab)
92
+		//
93
+		//		if len(fjtfLab.Result) > 0 {
94
+		//			// 根据获取的头部lab01获取检查结果
95
+		//
96
+		//			for _, info := range fjtfLab.Result {
97
+		//				lacResult, _ := CsnyGetLac(info.Lab01)
98
+		//				utils.InfoLog("lacResult:%v", lacResult)
99
+		//				var fjtfLac LacCsnyResult
100
+		//				if err := json.Unmarshal([]byte(lacResult), &fjtfLac); err != nil {
101
+		//					utils.ErrorLog("解析失败:%v", err)
102
+		//				}
103
+		//				fmt.Println(fjtfLac)
104
+		//				for _, cinfo := range fjtfLac.Result {
105
+		//					project_id := int64(0)
106
+		//					item_id := int64(0)
107
+		//					if len(cinfo.Bbx05a) > 0 {
108
+		//						project_id, _ = GetCsnyProjectID(org_id, cinfo.Bbx05a)
109
+		//						item_id, _ = GetCsnyItemID(org_id, cinfo.Bbx05a, cinfo.Bbx05, project_id)
110
+		//					} else {
111
+		//						project_id, _ = GetCsnyProjectID(org_id, cinfo.Bbx05)
112
+		//						item_id, _ = GetCsnyItemID(org_id, cinfo.Bbx05, cinfo.Bbx05, project_id)
113
+		//					}
114
+		//
115
+		//					tx := writeMiddleDb.Begin()
116
+		//					var inspection models.MiddleInspection
117
+		//					var inspection_reference models.MiddleInspectionReference
118
+		//
119
+		//					loc, _ := time.LoadLocation("Local")
120
+		//					theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", cinfo.Lac25, loc)
121
+		//					record_date := theTime.Unix()
122
+		//
123
+		//					if record_date == 0 {
124
+		//						record_date = time.Now().Unix()
125
+		//					}
126
+		//
127
+		//					inspect_date := time.Unix(record_date, 0).Format("2006-01-02 15:04")
128
+		//					var total int
129
+		//					var RangeOptions string
130
+		//					var RangeMin string
131
+		//					var RangeMax string
132
+		//
133
+		//					// // 判断检查类型
134
+		//					ItemType := 1
135
+		//					Range := strings.Split(cinfo.Lac15, "-")
136
+		//					if len(Range) > 1 {
137
+		//						RangeMin = cinfo.Lac13
138
+		//						RangeMax = cinfo.Lac14
139
+		//						ItemType = 1
140
+		//					} else {
141
+		//						ItemType = 2
142
+		//						RangeOptions = cinfo.Lac15
143
+		//					}
144
+		//
145
+		//					err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
146
+		//					// if inspection_reference.ID > 0 {
147
+		//					// 	ItemType = int64(inspection_reference.RangeType)
148
+		//					// }
149
+		//
150
+		//					if total <= 0 {
151
+		//						inspection_reference.OrgId = org_id
152
+		//						if len(cinfo.Bbx05a) > 0 {
153
+		//							inspection_reference.ProjectName = cinfo.Bbx05a
154
+		//							inspection_reference.Project = cinfo.Bbx05a
155
+		//						} else {
156
+		//							inspection_reference.ProjectName = cinfo.Bbx05
157
+		//							inspection_reference.Project = cinfo.Bbx05
158
+		//						}
159
+		//						inspection_reference.ProjectId = project_id
160
+		//						inspection_reference.ItemName = cinfo.Bbx05
161
+		//						inspection_reference.ItemId = item_id
162
+		//						inspection_reference.RangeType = ItemType
163
+		//						inspection_reference.RangeMin = RangeMin
164
+		//						inspection_reference.RangeMax = RangeMax
165
+		//						// inspection_reference.RangeValue = RangeValue
166
+		//						inspection_reference.RangeOptions = RangeOptions
167
+		//						inspection_reference.Unit = cinfo.Bdg02
168
+		//						inspection_reference.Status = 1
169
+		//						inspection_reference.CreatedTime = time.Now().Unix()
170
+		//						inspection_reference.UpdatedTime = time.Now().Unix()
171
+		//						inspection_reference.InspectDate = inspect_date
172
+		//						inspection_reference.UTime = inspect_date
173
+		//						err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
174
+		//						if err != nil {
175
+		//							tx.Rollback()
176
+		//						}
177
+		//					}
178
+		//
179
+		//					var itotal int
180
+		//					err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ?  and status = 1", org_id, project_id, item_id, record_date, patient_id).Find(&inspection).Count(&itotal).Error
181
+		//					if itotal <= 0 {
182
+		//						inspection.PatientId = patient_id
183
+		//						inspection.OrgId = org_id
184
+		//						inspection.ProjectId = project_id
185
+		//						inspection.ItemName = inspection_reference.ItemName
186
+		//						inspection.ProjectName = inspection_reference.ProjectName
187
+		//						inspection.InspectType = ItemType
188
+		//						inspection.ItemId = item_id
189
+		//						inspection.InspectValue = cinfo.Lac10
190
+		//						inspection.InspectDate = inspect_date
191
+		//						inspection.RecordDate = record_date
192
+		//						inspection.InspectTips = cinfo.Lac11
193
+		//						inspection.Status = 1
194
+		//						inspection.CreatedTime = time.Now().Unix()
195
+		//						inspection.UpdatedTime = time.Now().Unix()
196
+		//						inspection.UTime = inspect_date
197
+		//						inspection.HisUserId = strconv.FormatInt(patient_id, 10)
198
+		//						err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
199
+		//						if err != nil {
200
+		//							tx.Rollback()
201
+		//						}
202
+		//					}
203
+		//
204
+		//					tx.Commit()
205
+		//
206
+		//				}
207
+		//			}
208
+		//		}
209
+		//	} else {
210
+		//		continue
211
+		//	}
212
+		//}
40
 		for _, patient := range patientList {
213
 		for _, patient := range patientList {
41
 			if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
214
 			if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
42
 				patient_id := patient.ID
215
 				patient_id := patient.ID
43
 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
216
 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
44
 				// utils.InfoLog("VipStr:%v", VipStr)
217
 				// utils.InfoLog("VipStr:%v", VipStr)
45
 
218
 
46
-				result, _ := CsnyGetLab(patient.IdCardNo, syncTimeStr)
47
-				utils.InfoLog("result:%v", result)
219
+				result1, _ := CsnyGetLab(patient.IdCardNo, syncTimeStr)
220
+				utils.InfoLog("result:%v", result1)
48
 				var fjtfLab LabCsnyResult
221
 				var fjtfLab LabCsnyResult
49
-				if err := json.Unmarshal([]byte(result), &fjtfLab); err != nil {
222
+				if err := json.Unmarshal([]byte(result1), &fjtfLab); err != nil {
50
 					utils.ErrorLog("解析失败:%v", err)
223
 					utils.ErrorLog("解析失败:%v", err)
51
 				}
224
 				}
52
 				fmt.Println(fjtfLab)
225
 				fmt.Println(fjtfLab)
188
 		utils.ErrorLog("创建同步信息失败:%v", cwderr)
361
 		utils.ErrorLog("创建同步信息失败:%v", cwderr)
189
 		return
362
 		return
190
 	}
363
 	}
364
+
365
+	//var syncInfos models.MiddleSyncInfo
366
+	//syncInfos.OrgId = org_id_other
367
+	//syncInfos.SyncTime = time.Now().Unix()
368
+	//syncInfos.SyncResultType = 1
369
+	//syncInfos.SyncRsultRemark = "同步成功"
370
+	//syncInfos.SyncTotalNum = 0
371
+	//syncInfos.SyncSuccessNum = 0
372
+	//syncInfos.SyncInfo = ""
373
+	//syncInfos.CreateTime = time.Now().Unix()
374
+	//syncInfos.UpdateTime = time.Now().Unix()
375
+	//
376
+	//cwderrs := CreateSyncInfo(&syncInfos)
377
+	//if cwderrs != nil {
378
+	//	utils.ErrorLog("创建同步信息失败:%v", cwderrs)
379
+	//	return
380
+	//}
191
 	SyncToCsnytx()
381
 	SyncToCsnytx()
192
 	return
382
 	return
193
 }
383
 }
242
 	return str, inputLog
432
 	return str, inputLog
243
 }
433
 }
244
 
434
 
435
+func CsnyGetLabTj(patient_name string, synctime string) (string, string) {
436
+	inputData := make(map[string]interface{})
437
+
438
+	inputData["vaa05"] = patient_name
439
+	inputData["begintime"] = synctime
440
+
441
+	var inputLog string
442
+	bytesData, err := json.Marshal(inputData)
443
+	inputLog = string(bytesData)
444
+	fmt.Println(string(bytesData))
445
+	if err != nil {
446
+		fmt.Println(err.Error())
447
+		return err.Error(), ""
448
+	}
449
+	reader := bytes.NewReader(bytesData)
450
+	url := "http://218.104.146.179:9091/esb/listener/getLab1"
451
+
452
+	request, err := http.NewRequest("POST", url, reader)
453
+	if err != nil {
454
+		fmt.Println(err.Error())
455
+		return err.Error(), ""
456
+	}
457
+
458
+	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
459
+	request.Header.Set("code", "Xmrjyy")
460
+
461
+	client := http.Client{}
462
+	resp, err := client.Do(request)
463
+	if err != nil {
464
+		fmt.Println(err.Error())
465
+		return err.Error(), ""
466
+	}
467
+	respBytes, err := ioutil.ReadAll(resp.Body)
468
+	if err != nil {
469
+		fmt.Println(err.Error())
470
+		return err.Error(), ""
471
+	}
472
+	str := string(respBytes)
473
+	return str, inputLog
474
+}
475
+
245
 type LacCsnyResult struct {
476
 type LacCsnyResult struct {
246
 	Msg    string `json:"msg"`
477
 	Msg    string `json:"msg"`
247
 	Result []struct {
478
 	Result []struct {

+ 22 - 22
service/db.go View File

46
 	fmt.Println(mssqlstring)
46
 	fmt.Println(mssqlstring)
47
 	mssqlDb, err = gorm.Open("mssql", mssqlstring)
47
 	mssqlDb, err = gorm.Open("mssql", mssqlstring)
48
 	if err != nil {
48
 	if err != nil {
49
-		panic(err)
49
+		//panic(err)
50
 	}
50
 	}
51
-	mssqlDb.DB().SetMaxIdleConns(5)
52
-	mssqlDb.DB().SetMaxOpenConns(20)
53
-	mssqlDb.LogMode(true)
51
+	//mssqlDb.DB().SetMaxIdleConns(5)
52
+	//mssqlDb.DB().SetMaxOpenConns(20)
53
+	//mssqlDb.LogMode(true)
54
 	return
54
 	return
55
 }
55
 }
56
 
56
 
60
 
60
 
61
 func ConnectDB() {
61
 func ConnectDB() {
62
 
62
 
63
-	readHost := beego.AppConfig.String("readmysqlhost")
63
+	readHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
64
 	readPort := beego.AppConfig.String("readmysqlport")
64
 	readPort := beego.AppConfig.String("readmysqlport")
65
-	readUser := beego.AppConfig.String("readmysqluser")
66
-	readPass := beego.AppConfig.String("readmysqlpass")
65
+	readUser := "syh"
66
+	readPass := "Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4"
67
 	readName := beego.AppConfig.String("readmysqlname")
67
 	readName := beego.AppConfig.String("readmysqlname")
68
 
68
 
69
-	writeHost := beego.AppConfig.String("writemysqlhost")
69
+	writeHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
70
 	writePort := beego.AppConfig.String("writemysqlport")
70
 	writePort := beego.AppConfig.String("writemysqlport")
71
-	writeUser := beego.AppConfig.String("writemysqluser")
72
-	writePass := beego.AppConfig.String("writemysqlpass")
71
+	writeUser := "syh"
72
+	writePass := "Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4"
73
 	writeName := beego.AppConfig.String("writemysqlname")
73
 	writeName := beego.AppConfig.String("writemysqlname")
74
 
74
 
75
 	// tempwriteHost := beego.AppConfig.String("tempwritemysqlhost")
75
 	// tempwriteHost := beego.AppConfig.String("tempwritemysqlhost")
78
 	// tempwritePass := beego.AppConfig.String("tempwritemysqlpass")
78
 	// tempwritePass := beego.AppConfig.String("tempwritemysqlpass")
79
 	// tempwriteName := beego.AppConfig.String("tempwritemysqlname")
79
 	// tempwriteName := beego.AppConfig.String("tempwritemysqlname")
80
 
80
 
81
-	readUserHost := beego.AppConfig.String("readuserhost")
81
+	readUserHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
82
 	readUserPort := beego.AppConfig.String("readuserport")
82
 	readUserPort := beego.AppConfig.String("readuserport")
83
-	readUserUser := beego.AppConfig.String("readuseruser")
84
-	readUserPass := beego.AppConfig.String("readuserpass")
83
+	readUserUser := "syh"
84
+	readUserPass := "Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4"
85
 	readUserName := beego.AppConfig.String("readusername")
85
 	readUserName := beego.AppConfig.String("readusername")
86
 
86
 
87
 	// readRemoteHost := beego.AppConfig.String("readremotehost")
87
 	// readRemoteHost := beego.AppConfig.String("readremotehost")
90
 	// readRemotePass := beego.AppConfig.String("readremotepass")
90
 	// readRemotePass := beego.AppConfig.String("readremotepass")
91
 	// readRemoteName := beego.AppConfig.String("readremotename")
91
 	// readRemoteName := beego.AppConfig.String("readremotename")
92
 
92
 
93
-	writeUserHost := beego.AppConfig.String("writeuserhost")
93
+	writeUserHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
94
 	writeUserPort := beego.AppConfig.String("writeuserport")
94
 	writeUserPort := beego.AppConfig.String("writeuserport")
95
-	writeUserUser := beego.AppConfig.String("writeuseruser")
96
-	writeUserPass := beego.AppConfig.String("writeuserpass")
95
+	writeUserUser := "syh"
96
+	writeUserPass := "Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4"
97
 	writeUserName := beego.AppConfig.String("writeusername")
97
 	writeUserName := beego.AppConfig.String("writeusername")
98
 
98
 
99
-	readMiddleHost := beego.AppConfig.String("readmiddlehost")
99
+	readMiddleHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
100
 	readMiddlePort := beego.AppConfig.String("readmiddleport")
100
 	readMiddlePort := beego.AppConfig.String("readmiddleport")
101
-	readMiddleUser := beego.AppConfig.String("readmiddleuser")
102
-	readMiddlePass := beego.AppConfig.String("readmiddlepass")
101
+	readMiddleUser := "syh"
102
+	readMiddlePass := "Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4"
103
 	readMiddleName := beego.AppConfig.String("readmiddlename")
103
 	readMiddleName := beego.AppConfig.String("readmiddlename")
104
 
104
 
105
-	writeMiddleHost := beego.AppConfig.String("writemiddlehost")
105
+	writeMiddleHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
106
 	writeMiddlePort := beego.AppConfig.String("writemiddleport")
106
 	writeMiddlePort := beego.AppConfig.String("writemiddleport")
107
-	writeMiddleUser := beego.AppConfig.String("writemiddleuser")
108
-	writeMiddlePass := beego.AppConfig.String("writemiddlepass")
107
+	writeMiddleUser := "syh"
108
+	writeMiddlePass := "Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4"
109
 	writeMiddleName := beego.AppConfig.String("writemiddlename")
109
 	writeMiddleName := beego.AppConfig.String("writemiddlename")
110
 
110
 
111
 	// backupHost := beego.AppConfig.String("backuphost")
111
 	// backupHost := beego.AppConfig.String("backuphost")

+ 2 - 2
service/pajm_service.go View File

44
 // 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
44
 // 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
45
 func GetScpaProjectID(org_id int64, project_name string) (project_id int64, err error) {
45
 func GetScpaProjectID(org_id int64, project_name string) (project_id int64, err error) {
46
 	var inspection_reference models.MiddleInspectionReference
46
 	var inspection_reference models.MiddleInspectionReference
47
-	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
47
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ?", org_id, project_name).First(&inspection_reference).Error
48
 	if inspection_reference.ID > 0 {
48
 	if inspection_reference.ID > 0 {
49
 		return inspection_reference.ProjectId, err
49
 		return inspection_reference.ProjectId, err
50
 	} else {
50
 	} else {
60
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
60
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
61
 func GetScpaItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
61
 func GetScpaItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
62
 	var inspection_reference models.MiddleInspectionReference
62
 	var inspection_reference models.MiddleInspectionReference
63
-	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
63
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? and item_name = ?", org_id, project_name, item_name).First(&inspection_reference).Error
64
 	if inspection_reference.ID > 0 {
64
 	if inspection_reference.ID > 0 {
65
 		return inspection_reference.ItemId, err
65
 		return inspection_reference.ItemId, err
66
 	} else {
66
 	} else {

+ 4 - 0
service/sgyhs_service.go View File

71
 			if Result.Name == "陈永中" {
71
 			if Result.Name == "陈永中" {
72
 				Result.Name = "陈永忠"
72
 				Result.Name = "陈永忠"
73
 			}
73
 			}
74
+			if Result.Name == "朱小飞" {
75
+				Result.Name = "朱小妃"
76
+			}
77
+
74
 			patient, _ := GetUserInfoByName(org_id, Result.Name)
78
 			patient, _ := GetUserInfoByName(org_id, Result.Name)
75
 			if patient.ID > 0 {
79
 			if patient.ID > 0 {
76
 				project_id, _ := GetSgyhsProjectID(org_id, Result.DockingapplyitemName)
80
 				project_id, _ := GetSgyhsProjectID(org_id, Result.DockingapplyitemName)

+ 34 - 5
service/sssy_service.go View File

666
 
666
 
667
 func SyncSYData2() {
667
 func SyncSYData2() {
668
 	org_id := int64(10191)
668
 	org_id := int64(10191)
669
-	start_time := "2023-01-01"
670
-	end_time := "2023-11-22"
669
+	start_time := "2024-01-01"
670
+	end_time := "2024-04-15"
671
 	record, _ := GetLastSyncResultRecord(org_id)
671
 	record, _ := GetLastSyncResultRecord(org_id)
672
 	if record.ID > 0 {
672
 	if record.ID > 0 {
673
 		start_time = record.GpSyncEndDate
673
 		start_time = record.GpSyncEndDate
694
 		fmt.Println(list)
694
 		fmt.Println(list)
695
 		//插入到系统检验检查数据
695
 		//插入到系统检验检查数据
696
 		if len(list) > 0 {
696
 		if len(list) > 0 {
697
+			tx := writeMiddleDb.Begin()
697
 			for _, item := range list {
698
 			for _, item := range list {
698
 				project_id := int64(0)
699
 				project_id := int64(0)
699
 				patient, _ := GetPatientID(org_id, item.ListResult.PatientName)
700
 				patient, _ := GetPatientID(org_id, item.ListResult.PatientName)
701
 				if patient.ID == 0 {
702
 				if patient.ID == 0 {
702
 					continue
703
 					continue
703
 				}
704
 				}
704
-				tx := writeMiddleDb.Begin()
705
 				var inspection models.MiddleInspection
705
 				var inspection models.MiddleInspection
706
 				var inspection_reference models.MiddleInspectionReference
706
 				var inspection_reference models.MiddleInspectionReference
707
 
707
 
811
 						tx.Rollback()
811
 						tx.Rollback()
812
 					}
812
 					}
813
 				}
813
 				}
814
-				tx.Commit()
815
-
816
 			}
814
 			}
817
 			//插入一条查询检验检查结果记录状态数据
815
 			//插入一条查询检验检查结果记录状态数据
818
 			var info LisSyncResultStatusInfo
816
 			var info LisSyncResultStatusInfo
826
 			info.ResultDate = time.Now().Unix()
824
 			info.ResultDate = time.Now().Unix()
827
 			info.GpSyncEndDate = end_time
825
 			info.GpSyncEndDate = end_time
828
 			writeMiddleDb.Save(&info)
826
 			writeMiddleDb.Save(&info)
827
+
828
+			tx.Commit()
829
 		}
829
 		}
830
 	}
830
 	}
831
 	SyncToSssytx()
831
 	SyncToSssytx()
832
+	UpdateJg()
832
 }
833
 }
833
 
834
 
834
 func SyncToSssytx() {
835
 func SyncToSssytx() {
857
 	utils.SuccessLog("检验检查同步任务完成")
858
 	utils.SuccessLog("检验检查同步任务完成")
858
 }
859
 }
859
 
860
 
861
+func UpdateJg() error {
862
+	var inspections []models.Inspection
863
+	err = readDb.Model(&models.Inspection{}).Where("org_id = ? and project_id = ? and inspect_date >= ?  and status = 1", 10191, 15, 1704038400).Group("patient_id,inspect_date").Find(&inspections).Error
864
+	for _, info := range inspections {
865
+		var inspectionByOne []models.Inspection
866
+		err = readDb.Model(&models.Inspection{}).Where("org_id = ? and project_id = ? and inspect_date = ? and patient_id = ?  and status = 1", 10191, 15, info.InspectDate, info.PatientId).Find(&inspectionByOne).Error
867
+		if len(inspectionByOne) == 2 {
868
+			for _, tinfo := range inspectionByOne {
869
+				utils.InfoLog("date1: %v", tinfo.ID)
870
+				if tinfo.ItemId != 115 && tinfo.ItemId != 37 {
871
+					// 报告单里只有肌酐和尿素这两个项目要上传到“透后肾功能”里
872
+					continue
873
+				}
874
+				if tinfo.ItemId == 115 {
875
+					tinfo.ProjectId = 8060
876
+					tinfo.ItemId = 8060
877
+				}
878
+				if tinfo.ItemId == 37 {
879
+					tinfo.ProjectId = 8060
880
+					tinfo.ItemId = 8061
881
+				}
882
+				writeDb.Save(&tinfo)
883
+			}
884
+		}
885
+	}
886
+	return err
887
+}
888
+
860
 // 从机构将数据同步到中间库
889
 // 从机构将数据同步到中间库
861
 func SyncSssyInspection(data *models.MiddleInspection) error {
890
 func SyncSssyInspection(data *models.MiddleInspection) error {
862
 	tx := writeDb.Begin()
891
 	tx := writeDb.Begin()

+ 5 - 3
service/sy_service.go View File

92
 
92
 
93
 	org := &models.DataUploadConfig{
93
 	org := &models.DataUploadConfig{
94
 		OrgId:  org_id,
94
 		OrgId:  org_id,
95
-		DbHost: "127.0.0.1",
95
+		DbHost: "192.168.1.209",
96
 		DbPort: "1433",
96
 		DbPort: "1433",
97
 		DbPass: "Aa123456",
97
 		DbPass: "Aa123456",
98
 		DbUser: "kyys",
98
 		DbUser: "kyys",
239
 		}
239
 		}
240
 	}
240
 	}
241
 
241
 
242
+	// 第四步:关闭数据库连接
243
+	CloseDB(orgDb)
242
 	SyncToStsytx()
244
 	SyncToStsytx()
243
 	return
245
 	return
244
 }
246
 }
254
 // }
256
 // }
255
 
257
 
256
 func SyncToStsytx() {
258
 func SyncToStsytx() {
257
-
258
-	utils.TraceLog("检验检查同步任务开始执行")
259
 	org_id := int64(10223)
259
 	org_id := int64(10223)
260
+	utils.TraceLog("检验检查同步任务开始执行")
260
 
261
 
261
 	// 第一步:跟进org_id 去中间库查出需要同步的数据
262
 	// 第一步:跟进org_id 去中间库查出需要同步的数据
262
 	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
263
 	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
274
 			SyncInspection(&inspection)
275
 			SyncInspection(&inspection)
275
 		}
276
 		}
276
 	}
277
 	}
278
+	// 第四步:关闭数据库连接
277
 	utils.SuccessLog("检验检查同步任务完成")
279
 	utils.SuccessLog("检验检查同步任务完成")
278
 }
280
 }