张保健 3 周前
父节点
当前提交
95e93b3fba
共有 12 个文件被更改,包括 426 次插入127 次删除
  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 查看文件

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

+ 53 - 37
controllers/lis.go 查看文件

@@ -18,6 +18,22 @@ type LisController struct {
18 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 37
 func (c *LisController) Schedule() {
22 38
 	for i := 762429; i > 0; i-- {
23 39
 		schedule, err := service.GetScheduless(int64(i))
@@ -35,49 +51,49 @@ func (c *LisController) Schedule() {
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 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 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 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 98
 // 石狮盛誉LIS同步
83 99
 func (c *LisController) SyncSssy() {

+ 5 - 2
main.go 查看文件

@@ -18,7 +18,10 @@ func main() {
18 18
 	service.BeginAutoSyncLis()
19 19
 	//service.SyncStsyLis() //  汕头三优  打开程序马上运行LIS同步
20 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 26
 	beego.Run()
24 27
 }

+ 6 - 4
models/lis_model.go 查看文件

@@ -412,10 +412,11 @@ type MiddleInspection struct {
412 412
 	UTime        string `gorm:"column:u_time" json:"u_time" form:"u_time"`
413 413
 	IsSync       int    `gorm:"column:is_sync" json:"is_sync" form:"is_sync"`
414 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 422
 func (MiddleInspection) TableName() string {
@@ -448,6 +449,7 @@ type MiddleInspectionReference struct {
448 449
 	ItemCode         string `gorm:"column:item_code" json:"item_code" form:"item_code"`
449 450
 	XtProjectId      int64  `gorm:"column:xt_project_id" json:"xt_project_id" form:"xt_project_id"`
450 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 455
 func (MiddleInspectionReference) TableName() string {

+ 34 - 32
routers/router.go 查看文件

@@ -7,36 +7,38 @@ import (
7 7
 
8 8
 func init() {
9 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 查看文件

@@ -36,7 +36,7 @@ func BeginAutoSyncLis() {
36 36
 	//
37 37
 	//specys1 := "0 10 */2 * * ?" // 每两个小时同步长沙南雅医院
38 38
 	//createLisSyncCronJob.AddFunc(specys1, func() {
39
-	//	SyncCsnyLis()
39
+	//SyncCsnyLis()
40 40
 	//})
41 41
 	//
42 42
 	//spec := "0 50 1 * * ?" // 每天凌晨1点同步 监利大院的
@@ -99,6 +99,16 @@ func BeginAutoSyncLis() {
99 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 112
 	createLisSyncCronJob.Start()
103 113
 }
104 114
 

+ 234 - 3
service/csny_service.go 查看文件

@@ -12,15 +12,34 @@ import (
12 12
 	_ "github.com/jinzhu/gorm"
13 13
 	"io/ioutil"
14 14
 	"net/http"
15
+	"unicode/utf8"
15 16
 
16 17
 	"strconv"
17 18
 	"strings"
18 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 39
 // 福建天福医院透析中心Lis同步
22 40
 func SyncCsnyLis() (err error) {
23 41
 	org_id := int64(10340)
42
+	//org_id_other := int64(103401)
24 43
 
25 44
 	// 第一步:获取上一次同步的时间点
26 45
 	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
@@ -31,22 +50,176 @@ func SyncCsnyLis() (err error) {
31 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 61
 	sync_time_temp := time.Unix(sync_time, 0)
35 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 68
 	patientList, _ := GetPatientGzjhByOrgId(org_id)
39 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 213
 		for _, patient := range patientList {
41 214
 			if len(patient.IdCardNo) > 0 || len(patient.DialysisNo) > 0 {
42 215
 				patient_id := patient.ID
43 216
 				utils.InfoLog("IdCardNo:%v", patient.IdCardNo)
44 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 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 223
 					utils.ErrorLog("解析失败:%v", err)
51 224
 				}
52 225
 				fmt.Println(fjtfLab)
@@ -188,6 +361,23 @@ func SyncCsnyLis() (err error) {
188 361
 		utils.ErrorLog("创建同步信息失败:%v", cwderr)
189 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 381
 	SyncToCsnytx()
192 382
 	return
193 383
 }
@@ -242,6 +432,47 @@ func CsnyGetLab(id_card_no string, synctime string) (string, string) {
242 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 476
 type LacCsnyResult struct {
246 477
 	Msg    string `json:"msg"`
247 478
 	Result []struct {

+ 22 - 22
service/db.go 查看文件

@@ -46,11 +46,11 @@ func CreateSqlServiceDB(Host string, Port string, User string, Pass string, Name
46 46
 	fmt.Println(mssqlstring)
47 47
 	mssqlDb, err = gorm.Open("mssql", mssqlstring)
48 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 54
 	return
55 55
 }
56 56
 
@@ -60,16 +60,16 @@ func CloseDB(DB *gorm.DB) {
60 60
 
61 61
 func ConnectDB() {
62 62
 
63
-	readHost := beego.AppConfig.String("readmysqlhost")
63
+	readHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
64 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 67
 	readName := beego.AppConfig.String("readmysqlname")
68 68
 
69
-	writeHost := beego.AppConfig.String("writemysqlhost")
69
+	writeHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
70 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 73
 	writeName := beego.AppConfig.String("writemysqlname")
74 74
 
75 75
 	// tempwriteHost := beego.AppConfig.String("tempwritemysqlhost")
@@ -78,10 +78,10 @@ func ConnectDB() {
78 78
 	// tempwritePass := beego.AppConfig.String("tempwritemysqlpass")
79 79
 	// tempwriteName := beego.AppConfig.String("tempwritemysqlname")
80 80
 
81
-	readUserHost := beego.AppConfig.String("readuserhost")
81
+	readUserHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
82 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 85
 	readUserName := beego.AppConfig.String("readusername")
86 86
 
87 87
 	// readRemoteHost := beego.AppConfig.String("readremotehost")
@@ -90,22 +90,22 @@ func ConnectDB() {
90 90
 	// readRemotePass := beego.AppConfig.String("readremotepass")
91 91
 	// readRemoteName := beego.AppConfig.String("readremotename")
92 92
 
93
-	writeUserHost := beego.AppConfig.String("writeuserhost")
93
+	writeUserHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
94 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 97
 	writeUserName := beego.AppConfig.String("writeusername")
98 98
 
99
-	readMiddleHost := beego.AppConfig.String("readmiddlehost")
99
+	readMiddleHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
100 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 103
 	readMiddleName := beego.AppConfig.String("readmiddlename")
104 104
 
105
-	writeMiddleHost := beego.AppConfig.String("writemiddlehost")
105
+	writeMiddleHost := "kuyicloud2024lt.mysql.rds.aliyuncs.com"
106 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 109
 	writeMiddleName := beego.AppConfig.String("writemiddlename")
110 110
 
111 111
 	// backupHost := beego.AppConfig.String("backuphost")

+ 2 - 2
service/pajm_service.go 查看文件

@@ -44,7 +44,7 @@ func GetScpaLis(rdb *gorm.DB, synctime int64, hisuserid string) (record []*scpal
44 44
 // 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
45 45
 func GetScpaProjectID(org_id int64, project_name string) (project_id int64, err error) {
46 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 48
 	if inspection_reference.ID > 0 {
49 49
 		return inspection_reference.ProjectId, err
50 50
 	} else {
@@ -60,7 +60,7 @@ func GetScpaProjectID(org_id int64, project_name string) (project_id int64, err
60 60
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
61 61
 func GetScpaItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
62 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 64
 	if inspection_reference.ID > 0 {
65 65
 		return inspection_reference.ItemId, err
66 66
 	} else {

+ 4 - 0
service/sgyhs_service.go 查看文件

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

+ 34 - 5
service/sssy_service.go 查看文件

@@ -666,8 +666,8 @@ func SyncSYData(org_id int64) {
666 666
 
667 667
 func SyncSYData2() {
668 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 671
 	record, _ := GetLastSyncResultRecord(org_id)
672 672
 	if record.ID > 0 {
673 673
 		start_time = record.GpSyncEndDate
@@ -694,6 +694,7 @@ func SyncSYData2() {
694 694
 		fmt.Println(list)
695 695
 		//插入到系统检验检查数据
696 696
 		if len(list) > 0 {
697
+			tx := writeMiddleDb.Begin()
697 698
 			for _, item := range list {
698 699
 				project_id := int64(0)
699 700
 				patient, _ := GetPatientID(org_id, item.ListResult.PatientName)
@@ -701,7 +702,6 @@ func SyncSYData2() {
701 702
 				if patient.ID == 0 {
702 703
 					continue
703 704
 				}
704
-				tx := writeMiddleDb.Begin()
705 705
 				var inspection models.MiddleInspection
706 706
 				var inspection_reference models.MiddleInspectionReference
707 707
 
@@ -811,8 +811,6 @@ func SyncSYData2() {
811 811
 						tx.Rollback()
812 812
 					}
813 813
 				}
814
-				tx.Commit()
815
-
816 814
 			}
817 815
 			//插入一条查询检验检查结果记录状态数据
818 816
 			var info LisSyncResultStatusInfo
@@ -826,9 +824,12 @@ func SyncSYData2() {
826 824
 			info.ResultDate = time.Now().Unix()
827 825
 			info.GpSyncEndDate = end_time
828 826
 			writeMiddleDb.Save(&info)
827
+
828
+			tx.Commit()
829 829
 		}
830 830
 	}
831 831
 	SyncToSssytx()
832
+	UpdateJg()
832 833
 }
833 834
 
834 835
 func SyncToSssytx() {
@@ -857,6 +858,34 @@ func SyncToSssytx() {
857 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 890
 func SyncSssyInspection(data *models.MiddleInspection) error {
862 891
 	tx := writeDb.Begin()

+ 5 - 3
service/sy_service.go 查看文件

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