张保健 2 mēnešus atpakaļ
vecāks
revīzija
c4efccb744
7 mainītis faili ar 100 papildinājumiem un 47 dzēšanām
  1. 41 7
      controllers/lis.go
  2. 4 1
      main.go
  3. 11 1
      routers/router.go
  4. 27 19
      service/cron.go
  5. 12 14
      service/sssy_service.go
  6. 1 1
      service/sy_service.go
  7. 4 4
      service/xml_service.go

+ 41 - 7
controllers/lis.go Parādīt failu

@@ -9,7 +9,9 @@ import (
9 9
 	"fmt"
10 10
 	_ "github.com/astaxie/beego"
11 11
 	_ "github.com/jinzhu/gorm"
12
+	"net"
12 13
 	_ "strconv"
14
+	"strings"
13 15
 	"time"
14 16
 )
15 17
 
@@ -26,13 +28,45 @@ func (c *LisController) SyncChydLis() {
26 28
 	return
27 29
 }
28 30
 
29
-//func (c *LisController) Test() {
30
-//	service.SyncJhhjyyLis()
31
-//	c.ServeSuccessJSON(map[string]interface{}{
32
-//		"resultList": "12345",
33
-//	})
34
-//	return
35
-//}
31
+func (c *LisController) Test() {
32
+	var ipWhitelist = []string{"192.168.2.6", "192.168.1.1"}
33
+	ip := c.Ctx.Request.Header.Get("X-Forwarded-For")
34
+	if ip == "" {
35
+		// 如果没有 X-Forwarded-For,则使用 RemoteAddr
36
+		// 注意:RemoteAddr 可能包含端口号,需要进行处理
37
+		ip, _, _ = net.SplitHostPort(c.Ctx.Request.RemoteAddr)
38
+	}
39
+
40
+	// 如果 X-Forwarded-For 包含多个 IP 地址(逗号分隔),则通常取第一个
41
+	// 这通常是因为请求经过了多个代理
42
+	ips := strings.Split(ip, ",")
43
+	if len(ips) > 0 {
44
+		ip = strings.TrimSpace(ips[0])
45
+	}
46
+
47
+	utils.InfoLog("IP:%v", ip)
48
+
49
+	ipFlag := false
50
+	for _, allowedIP := range ipWhitelist {
51
+		if ip == allowedIP {
52
+			ipFlag = true
53
+		}
54
+	}
55
+
56
+	if ipFlag {
57
+		c.ServeSuccessJSON(map[string]interface{}{
58
+			"flag": "1",
59
+			"msg":  "认证通过",
60
+		})
61
+	} else {
62
+		c.ServeSuccessJSON(map[string]interface{}{
63
+			"flag": "0",
64
+			"msg":  "IP认证通过未通过",
65
+		})
66
+	}
67
+
68
+	return
69
+}
36 70
 
37 71
 func (c *LisController) Schedule() {
38 72
 	for i := 762429; i > 0; i-- {

+ 4 - 1
main.go Parādīt failu

@@ -15,7 +15,7 @@ func init() {
15 15
 }
16 16
 
17 17
 func main() {
18
-	service.BeginAutoSyncLis()
18
+	//service.BeginAutoSyncLis()
19 19
 	//service.SyncStsyLis() //  汕头三优  打开程序马上运行LIS同步
20 20
 	//service.SyncLisSgyhs() //  韶关源和盛  打开程序马上运行LIS同步
21 21
 	//service.SyncLisPljx(10597) //  揭阳景熹透析中心  打开程序马上运行LIS同步
@@ -25,5 +25,8 @@ func main() {
25 25
 	//service.SyncSclsyyyyyz() // 石狮盛誉血液透析中心  打开程序马上运行LIS同步
26 26
 	//service.SyncSccdkfyyLis() // 成都城东康复医院  打开程序马上运行LIS同步
27 27
 	//service.SyncSclsyyyyyz(orgDb) // 深圳五洲医院  打开程序马上运行LIS同步
28
+	//service.SyncGzkyLis() // 广州康允 打开程序马上运行LIS同步
29
+	//service.SyncLisZqshtx() // 肇庆三鹤 打开程序马上运行LIS同步
30
+	//service.SyncBjncHis()
28 31
 	beego.Run()
29 32
 }

+ 11 - 1
routers/router.go Parādīt failu

@@ -3,9 +3,19 @@ package routers
3 3
 import (
4 4
 	"IC/controllers"
5 5
 	"github.com/astaxie/beego"
6
+	"github.com/astaxie/beego/plugins/cors"
6 7
 )
7 8
 
8 9
 func init() {
10
+	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
11
+		//AllowAllOrigins:  true,
12
+		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com", "https://mobile.kuyicloud.com"},
13
+		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
14
+		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
15
+		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission", "KyToken"},
16
+		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
17
+		AllowCredentials: true,
18
+	}))
9 19
 	beego.Router("/", &controllers.MainController{})
10 20
 	//beego.Router("/api/lis/getlist", &controllers.LisController{}, "get:GetList")
11 21
 	//beego.Router("/api/lis/synctobase", &controllers.LisController{}, "get:SyncToBase")
@@ -40,5 +50,5 @@ func init() {
40 50
 	//beego.Router("/api/lis/syncbjnc", &controllers.LisController{}, "get:SyncBjncLis")
41 51
 	//beego.Router("/api/lis/synczhra", &controllers.LisController{}, "get:SyncZhraLis")
42 52
 	beego.Router("/api/lis/syncchyd", &controllers.LisController{}, "get:SyncChydLis")
43
-	//beego.Router("/test", &controllers.LisController{}, "get:Test")
53
+	beego.Router("/test", &controllers.LisController{}, "get:Test")
44 54
 }

+ 27 - 19
service/cron.go Parādīt failu

@@ -5,10 +5,8 @@ import (
5 5
 	"IC/utils"
6 6
 	"encoding/json"
7 7
 	_ "fmt"
8
-	oracle "github.com/dzwvip/gorm-oracle"
9 8
 	_ "github.com/jinzhu/gorm"
10 9
 	"github.com/robfig/cron/v3"
11
-	"gorm.io/gorm"
12 10
 	_ "strings"
13 11
 	"time"
14 12
 )
@@ -31,11 +29,11 @@ func BeginAutoSyncLis() {
31 29
 	utils.InfoLog("开启自动检验检查同步定时任务")
32 30
 	createLisSyncCronJob := newWithSeconds()
33 31
 
34
-	orgDb, err := gorm.Open(oracle.Open("oracle://zjybase:zjybase@10.0.0.248:1521/orcl"), &gorm.Config{})
35
-
36
-	if err != nil {
37
-		utils.InfoLog("创建数据库连接失败:%v", err)
38
-	}
32
+	//orgDb, err := gorm.Open(oracle.Open("oracle://zjybase:zjybase@10.0.0.248:1521/orcl"), &gorm.Config{})
33
+	//
34
+	//if err != nil {
35
+	//	utils.InfoLog("创建数据库连接失败:%v", err)
36
+	//}
39 37
 
40 38
 	//specys := "0 0 */1 * * ?" // 每天凌晨3点同步 唐山朝阳医院
41 39
 	//createLisSyncCronJob.AddFunc(specys, func() {
@@ -82,10 +80,10 @@ func BeginAutoSyncLis() {
82 80
 	//	SyncLisSzwz()
83 81
 	//})
84 82
 
85
-	//spec8 := "0 25 */2 * * ?" // 每个小时同步一次 汕头三优透析中心LIS对接,本地部署的
86
-	//createLisSyncCronJob.AddFunc(spec8, func() {
87
-	//	SyncStsyLis()
88
-	//})
83
+	spec8 := "0 25 */3 * * ?" // 每个小时同步一次 汕头三优透析中心LIS对接,本地部署的
84
+	createLisSyncCronJob.AddFunc(spec8, func() {
85
+		SyncStsyLis()
86
+	})
89 87
 
90 88
 	//spec9 := "0 57 * * * ?" // 每个小时同步一次 遵化仁爱医院LIS对接,本地部署的
91 89
 	//createLisSyncCronJob.AddFunc(spec9, func() {
@@ -132,15 +130,25 @@ func BeginAutoSyncLis() {
132 130
 	//	SyncJhhjyyLis()
133 131
 	//})
134 132
 
135
-	spec18 := "1 * * * * ?" // 每个30秒同步一次 四川乐山友谊医院医嘱对接,本地部署的
136
-	createLisSyncCronJob.AddFunc(spec18, func() {
137
-		SyncSclsyyyyyz(orgDb)
138
-	})
133
+	//spec18 := "1 * * * * ?" // 每个30秒同步一次 四川乐山友谊医院医嘱对接,本地部署的
134
+	//createLisSyncCronJob.AddFunc(spec18, func() {
135
+	//	SyncSclsyyyyyz(orgDb)
136
+	//})
139 137
 
140
-	spec19 := "* 35 */4 * * ?" // 每个2个小时同步一次 四川乐山友谊医院LIS对接,本地部署的
141
-	createLisSyncCronJob.AddFunc(spec19, func() {
142
-		SyncScyyyyLis()
143
-	})
138
+	//spec19 := "* 35 */4 * * ?" // 每个2个小时同步一次 四川乐山友谊医院LIS对接,本地部署的
139
+	//createLisSyncCronJob.AddFunc(spec19, func() {
140
+	//	SyncScyyyyLis()
141
+	//})
142
+
143
+	//spec20 := "* 15 */2 * * ?" // 每个2个小时同步一次 四川乐山友谊医院LIS对接,本地部署的
144
+	//createLisSyncCronJob.AddFunc(spec20, func() {
145
+	//	SyncGzkyLis()
146
+	//})
147
+
148
+	//spec21 := "1 * * * * ?" // 每个30秒同步一次 四川乐山友谊医院医嘱对接,本地部署的
149
+	//createLisSyncCronJob.AddFunc(spec21, func() {
150
+	//	SyncBjncHis()
151
+	//})
144 152
 
145 153
 	createLisSyncCronJob.Start()
146 154
 }

+ 12 - 14
service/sssy_service.go Parādīt failu

@@ -666,7 +666,7 @@ func UploadSYData(org_id int64) {
666 666
 
667 667
 func SyncSYData2() {
668 668
 	org_id := int64(10191)
669
-	start_time := "2024-04-20"
669
+	start_time := "2022-01-10"
670 670
 	end_time := "2024-04-26"
671 671
 	record, _ := GetLastSyncResultRecord(org_id)
672 672
 	if record.ID > 0 {
@@ -675,7 +675,7 @@ func SyncSYData2() {
675 675
 	}
676 676
 	loc, _ := time.LoadLocation("Local")
677 677
 	theTime, _ := time.ParseInLocation("2006-01-02", start_time, loc)
678
-	newtheTime := theTime.Unix() - 60*60*24*3
678
+	newtheTime := theTime.Unix() - 60*60*24
679 679
 
680 680
 	SyncTime := time.Unix(newtheTime, 0)
681 681
 	syncTimeStr := SyncTime.Format("2006-01-02")
@@ -821,7 +821,7 @@ func SyncSYData2() {
821 821
 	}
822 822
 
823 823
 	SyncToSssytx()
824
-	UpdateJg()
824
+	//UpdateJg()
825 825
 }
826 826
 
827 827
 func SyncToSssytx() {
@@ -830,21 +830,19 @@ func SyncToSssytx() {
830 830
 	org_id := int64(10191)
831 831
 
832 832
 	// 第一步:跟进org_id 去中间库查出需要同步的数据
833
-	//inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
833
+	inspection_references, _ := GetSyncInspectionReferenceByOrgId(org_id)
834 834
 	inspections, _ := GetSyncInspectionByOrgId(org_id)
835 835
 
836 836
 	// 第二步:将数据同步到业务库
837
-	//if len(inspection_references) > 0 {
838
-	//	for _, inspection_reference := range inspection_references {
839
-	//		SyncInspectionReference(&inspection_reference)
840
-	//	}
841
-	//}
837
+	if len(inspection_references) > 0 {
838
+		for _, inspection_reference := range inspection_references {
839
+			SyncInspectionReference(&inspection_reference)
840
+		}
841
+	}
842 842
 
843 843
 	if len(inspections) > 0 {
844 844
 		for _, inspection := range inspections {
845
-			if inspection.SysProjectId > 0 && inspection.SysItemId > 0 {
846
-				SyncSssyInspection(&inspection)
847
-			}
845
+			SyncSssyInspection(&inspection)
848 846
 		}
849 847
 	}
850 848
 	utils.SuccessLog("检验检查同步任务完成")
@@ -890,9 +888,9 @@ func SyncSssyInspection(data *models.MiddleInspection) error {
890 888
 		inspection.PatientId = data.PatientId
891 889
 		inspection.ProjectName = data.ProjectName
892 890
 		// inspection.Project = data.ProjectName
893
-		inspection.ProjectId = data.SysProjectId
891
+		inspection.ProjectId = data.ProjectId
894 892
 		inspection.ItemName = data.ItemName
895
-		inspection.ItemId = data.SysItemId
893
+		inspection.ItemId = data.ItemId
896 894
 		inspection.InspectType = int64(data.InspectType)
897 895
 		inspection.InspectValue = data.InspectValue
898 896
 		inspection.InspectTips = data.InspectTips

+ 1 - 1
service/sy_service.go Parādīt failu

@@ -192,7 +192,7 @@ func SyncStsyLis() (err error) {
192 192
 					}
193 193
 				}
194 194
 				var itotal int
195
-				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, recordTimeStr, patient.ID).Find(&inspection).Count(&itotal).Error
195
+				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, recordTimeInt, patient.ID).Find(&inspection).Count(&itotal).Error
196 196
 				if itotal <= 0 {
197 197
 					// inspection.InspectValue = strings.Replace(LisInfo.Testresult, "&gt;", ">", -1)
198 198
 					// inspection.InspectValue = strings.Replace(LiLisInfo.Testresult, "&lt;", "<", -1)

+ 4 - 4
service/xml_service.go Parādīt failu

@@ -38,7 +38,7 @@ func GetGPReportListData(start_date string, end_date string, key string) (result
38 38
 	}
39 39
 
40 40
 	// 创建POST请求
41
-	url := "http://gpis.cnhiqc.com:9799/InstituteLISService.asmx"
41
+	url := "https://gpis.cnhiqc.com/api/InstituteLISService.asmx"
42 42
 	req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
43 43
 	if err != nil {
44 44
 		fmt.Println("Request creation error:", err)
@@ -192,7 +192,7 @@ func GetGPResultDataTwo(item models.GPReportListResultData, key string) (results
192 192
 		}
193 193
 
194 194
 		// 创建POST请求
195
-		url := "http://gpis.cnhiqc.com:9799/InstituteLISService.asmx"
195
+		url := "https://gpis.cnhiqc.com/api/InstituteLISService.asmx"
196 196
 		req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
197 197
 		if err != nil {
198 198
 			fmt.Println("Request creation error:", err)
@@ -273,7 +273,7 @@ func GetGPResultDataTwo(item models.GPReportListResultData, key string) (results
273 273
 			}
274 274
 
275 275
 			// 创建POST请求
276
-			url := "http://gpis.cnhiqc.com:9799/InstituteLISService.asmx"
276
+			url := "https://gpis.cnhiqc.com/api/InstituteLISService.asmx"
277 277
 			req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
278 278
 			if err != nil {
279 279
 				fmt.Println("Request creation error:", err)
@@ -358,7 +358,7 @@ func PostInspectApply(key string, apply models.JYApply, list []models.CustomerAp
358 358
 	fmt.Println(string(requestBody))
359 359
 
360 360
 	// 创建POST请求
361
-	url := "http://gpis.cnhiqc.com:9799/InstituteLISService.asmx"
361
+	url := "https://gpis.cnhiqc.com/api/InstituteLISService.asmx"
362 362
 	req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
363 363
 	if err != nil {
364 364
 		fmt.Println("Request creation error:", err)