张保健 1 month ago
parent
commit
42db3d0a7b

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = IC
2
-httpport = 9818
2
+httpport = 9859
3 3
 runmode = prod
4 4
 
5 5
 copyrequestbody = true

+ 9 - 2
main.go View File

@@ -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同步
@@ -27,6 +27,13 @@ func main() {
27 27
 	//service.SyncSclsyyyyyz(orgDb) // 深圳五洲医院  打开程序马上运行LIS同步
28 28
 	//service.SyncGzkyLis() // 广州康允 打开程序马上运行LIS同步
29 29
 	//service.SyncLisZqshtx() // 肇庆三鹤 打开程序马上运行LIS同步
30
-	//service.SyncBjncHis()
30
+	//service.SyncScyyyyLis() // 四川乐生友谊医院 打开程序马上运行LIS同步
31
+	//service.SyncGxlsskyz() // 广西灵山盛康 医嘱
32
+	//service.SyncSzxdyyLis() // 山西朔州现代医院  打开程序马上运行LIS同步
33
+	//service.SyncSzxdyyyz() // 山西朔州现代医院  打开程序马上运行医嘱同步
34
+	//service.SyncSHLisFunc() // 舒和LIS对接
35
+	//service.SyncLisLaxk() //乐安祥康LIS对接
36
+	//service.SyncLisPljx(10597) // 揭阳LIS对接
37
+	service.SyncLisPljx(10599) // 揭阳LIS对接
31 38
 	beego.Run()
32 39
 }

+ 90 - 0
models/report_result.go View File

@@ -118,3 +118,93 @@ type HisLabelPrintInfo struct {
118 118
 func (HisLabelPrintInfo) TableName() string {
119 119
 	return "his_label_print_info"
120 120
 }
121
+
122
+type XtHisProjectTeam struct {
123
+	ID          int64   `gorm:"column:id" json:"id" form:"id"`
124
+	ProjectTeam string  `gorm:"column:project_team" json:"project_team" form:"project_team"`
125
+	Price       float64 `gorm:"column:price" json:"price" form:"price"`
126
+	Pinyin      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
127
+	Wubi        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
128
+	TubeColor   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
129
+	TeamType    int64   `gorm:"column:team_type" json:"team_type" form:"team_type"`
130
+	Remark      string  `gorm:"column:remark" json:"remark" form:"remark"`
131
+	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
132
+	Status      int64   `gorm:"column:status" json:"status" form:"status"`
133
+	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
134
+	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
135
+	ProjectId   string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
136
+	ItemId      string  `gorm:"column:item_id" json:"item_id" form:"item_id"`
137
+	Sort        int64   `gorm:"column:sort" json:"sort" form:"sort"`
138
+}
139
+
140
+func (XtHisProjectTeam) TableName() string {
141
+	return "xt_his_project_team"
142
+}
143
+
144
+type XtHisProjectList struct {
145
+	ID           int64        `gorm:"column:id" json:"id" form:"id"`
146
+	Number       int64        `gorm:"column:number" json:"number" form:"number"`
147
+	UserOrgId    int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
148
+	ProjectId    int64        `gorm:"column:project_id" json:"project_id" form:"project_id"`
149
+	Status       int64        `gorm:"column:status" json:"status" form:"status"`
150
+	CreatedTime  int64        `gorm:"column:created_time" json:"created_time" form:"created_time"`
151
+	UpdatedTime  int64        `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
152
+	TeamId       int64        `gorm:"column:team_id" json:"team_id" form:"team_id"`
153
+	Type         int64        `gorm:"column:type" json:"type" form:"type"`
154
+	XtHisProject XtHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
155
+	PN           string       `gorm:"-" json:"pn" form:"pn"`
156
+}
157
+
158
+func (XtHisProjectList) TableName() string {
159
+	return "xt_his_project_list"
160
+}
161
+
162
+type XtHisProject struct {
163
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
164
+	ProjectName                 string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
165
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
166
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
167
+	Price                       float64 `gorm:"column:price" json:"price" form:"price"`
168
+	Unit                        string  `gorm:"column:unit" json:"unit" form:"unit"`
169
+	CostClassify                int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
170
+	ExecutiveSection            int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
171
+	MedicalCoverage             int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
172
+	StatisticalClassification   int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
173
+	DiseaseDirectory            int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
174
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
175
+	MedicalCode                 string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
176
+	TubeColor                   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
177
+	MedicalStatus               int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
178
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
179
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
180
+	DefaultNumber               string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
181
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
182
+	IsCharge                    int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
183
+	IsEstimate                  int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
184
+	IsWorkload                  int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
185
+	Sort                        string  `gorm:"column:sort" json:"sort" form:"sort"`
186
+	DoctorAdvice                int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
187
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
188
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
189
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
190
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
191
+	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
192
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
193
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
194
+	NumberDays                  string  `gorm:"column:number_days" json:"number_days" form:"number_days"`
195
+	Total                       string  `gorm:"column:total" json:"total" form:"total"`
196
+	Category                    int64   `gorm:"column:category" json:"category" form:"category"`
197
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
198
+	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
199
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
200
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
201
+	IsPrint                     int64   `gorm:"column:is_print" json:"is_print" form:"is_print"`
202
+	FirstLetter                 string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
203
+	Bbx01                       string  `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
204
+	Bby01                       string  `gorm:"column:bby01" json:"bby01" form:"bby01"`
205
+	ZuobiaoId                   string  `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
206
+}
207
+
208
+func (XtHisProject) TableName() string {
209
+	return "xt_his_project"
210
+}

+ 50 - 24
service/cron.go View File

@@ -1,14 +1,14 @@
1 1
 package service
2 2
 
3 3
 import (
4
+	"IC/models"
5
+	"IC/utils"
4 6
 	"encoding/json"
5 7
 	_ "fmt"
8
+	_ "github.com/jinzhu/gorm"
9
+	"github.com/robfig/cron/v3"
6 10
 	_ "strings"
7 11
 	"time"
8
-
9
-	"IC/models"
10
-	"IC/utils"
11
-	_ "github.com/jinzhu/gorm"
12 12
 )
13 13
 
14 14
 // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
@@ -19,15 +19,15 @@ func init() {
19 19
 }
20 20
 
21 21
 // 返回一个支持至 秒 级别的 cron
22
-//func newWithSeconds() *cron.Cron {
23
-//	secondParser := cron.NewParser(cron.Second | cron.Minute |
24
-//		cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)
25
-//	return cron.New(cron.WithParser(secondParser), cron.WithChain())
26
-//}
22
+func newWithSeconds() *cron.Cron {
23
+	secondParser := cron.NewParser(cron.Second | cron.Minute |
24
+		cron.Hour | cron.Dom | cron.Month | cron.DowOptional | cron.Descriptor)
25
+	return cron.New(cron.WithParser(secondParser), cron.WithChain())
26
+}
27 27
 
28 28
 func BeginAutoSyncLis() {
29 29
 	utils.InfoLog("开启自动检验检查同步定时任务")
30
-	//createLisSyncCronJob := newWithSeconds()
30
+	createLisSyncCronJob := newWithSeconds()
31 31
 
32 32
 	//orgDb, err := gorm.Open(oracle.Open("oracle://zjybase:zjybase@10.0.0.248:1521/orcl"), &gorm.Config{})
33 33
 	//
@@ -35,6 +35,12 @@ func BeginAutoSyncLis() {
35 35
 	//	utils.InfoLog("创建数据库连接失败:%v", err)
36 36
 	//}
37 37
 
38
+	//orgDb, err := gorm.Open(oracle.Open("oracle://BSLIS52:zhsoft@172.9.200.3:1521/JYK"), &gorm.Config{})
39
+	//
40
+	//if err != nil {
41
+	//	utils.InfoLog("syncTimeStr:%v", err)
42
+	//}
43
+
38 44
 	//specys := "0 0 */1 * * ?" // 每天凌晨3点同步 唐山朝阳医院
39 45
 	//createLisSyncCronJob.AddFunc(specys, func() {
40 46
 	//	SyncTscyLis()
@@ -47,7 +53,7 @@ func BeginAutoSyncLis() {
47 53
 	//
48 54
 	//spec := "0 50 1 * * ?" // 每天凌晨1点同步 监利大院的
49 55
 	//createLisSyncCronJob.AddFunc(spec, func() {
50
-	//	SyncHbdyLis()
56
+	//SyncHbdyLis()
51 57
 	//})
52 58
 	//
53 59
 	//spec2 := "0 50 2 * * ?" // 每天凌晨2点同步 龙岗二院
@@ -80,9 +86,9 @@ func BeginAutoSyncLis() {
80 86
 	//	SyncLisSzwz()
81 87
 	//})
82 88
 
83
-	//spec8 := "0 25 */3 * * ?" // 每个小时同步一次 汕头三优透析中心LIS对接,本地部署的
89
+	//spec8 := "0 25 */12 * * ?" // 每个小时同步一次 汕头三优透析中心LIS对接,本地部署的
84 90
 	//createLisSyncCronJob.AddFunc(spec8, func() {
85
-	SyncStsyLis()
91
+	//	SyncStsyLis()
86 92
 	//})
87 93
 
88 94
 	//spec9 := "0 57 * * * ?" // 每个小时同步一次 遵化仁爱医院LIS对接,本地部署的
@@ -95,15 +101,15 @@ func BeginAutoSyncLis() {
95 101
 	//	SyncLisSgyhs()
96 102
 	//})
97 103
 
98
-	//spec11 := "0 20 */2 * * ?" // 每个小时同步一次 揭阳景熹LIS对接,本地部署的
99
-	//createLisSyncCronJob.AddFunc(spec11, func() {
100
-	//	SyncLisPljx(10597)
101
-	//})
104
+	spec11 := "0 20 */12 * * ?" // 每个小时同步一次 揭阳景熹LIS对接,本地部署的
105
+	createLisSyncCronJob.AddFunc(spec11, func() {
106
+		SyncLisPljx(10597)
107
+	})
102 108
 
103
-	//spec12 := "0 40 */2 * * ?" // 每个小时同步一次 普宁景熹LIS对接,本地部署的
104
-	//createLisSyncCronJob.AddFunc(spec12, func() {
105
-	//	SyncLisPljx(10599)
106
-	//})
109
+	spec12 := "0 40 */12 * * ?" // 每个小时同步一次 普宁景熹LIS对接,本地部署的
110
+	createLisSyncCronJob.AddFunc(spec12, func() {
111
+		SyncLisPljx(10599)
112
+	})
107 113
 
108 114
 	//spec13 := "0 10 * * * ?" // 每个小时同步一次 唐山遵化仁爱医院LIS对接,本地部署的
109 115
 	//createLisSyncCronJob.AddFunc(spec13, func() {
@@ -122,7 +128,7 @@ func BeginAutoSyncLis() {
122 128
 
123 129
 	//spec16 := "0 20 */2 * * ?" // 每个小时同步一次 深圳五洲医院,本地部署的
124 130
 	//createLisSyncCronJob.AddFunc(spec16, func() {
125
-	//	SyncLisSzwz()
131
+	//	SyncLisSzwz(orgDb)
126 132
 	//})
127 133
 
128 134
 	//spec17 := "0 20 */2 * * ?" // 每个小时同步一次 湖南嘉禾恒佳医院,本地部署的
@@ -132,7 +138,7 @@ func BeginAutoSyncLis() {
132 138
 
133 139
 	//spec18 := "1 * * * * ?" // 每个30秒同步一次 四川乐山友谊医院医嘱对接,本地部署的
134 140
 	//createLisSyncCronJob.AddFunc(spec18, func() {
135
-	//	SyncSclsyyyyyz(orgDb)
141
+	//SyncSclsyyyyyz(orgDb)
136 142
 	//})
137 143
 
138 144
 	//spec19 := "* 35 */4 * * ?" // 每个2个小时同步一次 四川乐山友谊医院LIS对接,本地部署的
@@ -150,7 +156,27 @@ func BeginAutoSyncLis() {
150 156
 	//	SyncBjncHis()
151 157
 	//})
152 158
 
153
-	//createLisSyncCronJob.Start()
159
+	//spec22 := "1 * * * * ?" // 每个30秒同步一次 广西灵山盛康医嘱对接,本地部署的
160
+	//createLisSyncCronJob.AddFunc(spec22, func() {
161
+	//	SyncGxlsskyz()
162
+	//})
163
+
164
+	//spec23 := "1 * * * * ?" // 每个30秒同步一次 朔州现代医院医嘱对接,本地部署的
165
+	//createLisSyncCronJob.AddFunc(spec23, func() {
166
+	//	SyncSzxdyyyz()
167
+	//})
168
+
169
+	//spec24 := "* 25 */2 * * ?" // 每个2个小时同步一次 四川乐山友谊医院LIS对接,本地部署的
170
+	//createLisSyncCronJob.AddFunc(spec24, func() {
171
+	//	SyncSzxdyyLis()
172
+	//})
173
+
174
+	//spec25 := "* 10 */2 * * ?" // 每个30秒同步一次 朔州现代医院医嘱对接,本地部署的
175
+	//createLisSyncCronJob.AddFunc(spec25, func() {
176
+	//	SyncSHLisFunc()
177
+	//})
178
+
179
+	createLisSyncCronJob.Start()
154 180
 }
155 181
 
156 182
 func AutoSyncLis() {

+ 22 - 15
service/lgty_service.go View File

@@ -40,7 +40,7 @@ func SyncLisLgty() (err error) {
40 40
 				if inspectionLastInfo.ID > 0 {
41 41
 					sync_time = inspectionLastInfo.CreatedTime
42 42
 				} else {
43
-					sync_time = 1672502400
43
+					sync_time = 1704038400
44 44
 				}
45 45
 			}
46 46
 
@@ -170,7 +170,7 @@ func ReportInfoHandle(org_id int64) {
170 170
 					//return
171 171
 				}
172 172
 				report_handle.ReportInfoItemNum = int64(report_info_item_num)
173
-				project_id, _ := GetProjectID(org_id, report_handle.Item)
173
+				//project_id, _ := GetProjectID(org_id, report_handle.Item)
174 174
 				patient, perr := GetUserInfoByAdmission(report_handle.PatientId, org_id)
175 175
 				if perr != nil {
176 176
 					utils.ErrorLog("查询病人信息失败:%v", perr)
@@ -183,8 +183,8 @@ func ReportInfoHandle(org_id int64) {
183 183
 							continue
184 184
 						}
185 185
 						// 获取该小项的检验检查item_id,如果没有,则创建一个
186
-						item_id, _ := GetItemID(org_id, report_handle.Item, reportInfo.ItemName, project_id)
187
-						_, _, syerr := LgthSync(&report_handle, reportInfo, project_id, item_id, org_id, patient.ID, patient.AdmissionNumber)
186
+						//item_id, _ := GetItemID(org_id, report_handle.Item, reportInfo.ItemName, project_id)
187
+						_, _, syerr := LgthSync(&report_handle, reportInfo, org_id, patient.ID, patient.AdmissionNumber)
188 188
 						if syerr != nil {
189 189
 							utils.ErrorLog("创建同步信息失败:%v", syerr)
190 190
 							return
@@ -194,7 +194,7 @@ func ReportInfoHandle(org_id int64) {
194 194
 			}
195 195
 		}
196 196
 	}
197
-	SyncToLgey()
197
+	//SyncToLgey()
198 198
 }
199 199
 
200 200
 func SyncToLgey() {
@@ -221,10 +221,12 @@ func SyncToLgey() {
221 221
 }
222 222
 
223 223
 // 从机构将数据同步到中间库
224
-func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int64, item_id int64, org_id int64, patient_id int64, his_user_id string) (*models.MiddleInspectionReference, *models.MiddleInspection, error) {
224
+func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, org_id int64, patient_id int64, his_user_id string) (*models.MiddleInspectionReference, *models.MiddleInspection, error) {
225 225
 	tx := writeMiddleDb.Begin()
226 226
 	var inspection models.MiddleInspection
227 227
 	var inspection_reference models.MiddleInspectionReference
228
+	//var project_id int64
229
+	//var item_id int64
228 230
 	recordDateStr := Head.CheckTime
229 231
 	utils.InfoLog("打印测试: %v", recordDateStr)
230 232
 
@@ -259,21 +261,26 @@ func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int
259 261
 		RangeOptions = report.Reference
260 262
 	}
261 263
 
262
-	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
264
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and item_name = ? and range_value = ? and status = 1", org_id, report.ItemName, report.Reference).Find(&inspection_reference).Count(&total).Error
263 265
 	if inspection_reference.ID > 0 {
264 266
 		ItemType = inspection_reference.RangeType
267
+		//project_id = inspection_reference.ProjectId
268
+		//item_id = inspection_reference.ItemId
265 269
 	}
266 270
 	if total <= 0 && len(Head.Item) > 0 {
271
+		projectId, _ := GetProjectID(org_id, Head.Item)
272
+		itemId, _ := GetItemID(org_id, Head.Item, report.ItemName, projectId)
273
+
267 274
 		inspection_reference.OrgId = org_id
268 275
 		inspection_reference.ProjectName = Head.Item
269 276
 		inspection_reference.Project = Head.Item
270
-		inspection_reference.ProjectId = project_id
277
+		inspection_reference.ProjectId = projectId
271 278
 		inspection_reference.ItemName = report.ItemName
272
-		inspection_reference.ItemId = item_id
279
+		inspection_reference.ItemId = itemId
273 280
 		inspection_reference.RangeType = ItemType
274 281
 		inspection_reference.RangeMin = RangeMin
275 282
 		inspection_reference.RangeMax = RangeMax
276
-		// inspection_reference.RangeValue = RangeValue
283
+		inspection_reference.RangeValue = report.Reference
277 284
 		inspection_reference.RangeOptions = RangeOptions
278 285
 		inspection_reference.Unit = report.Unit
279 286
 		inspection_reference.Status = 1
@@ -287,15 +294,15 @@ func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int
287 294
 		}
288 295
 	}
289 296
 
290
-	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
297
+	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, inspection_reference.ProjectId, inspection_reference.ItemId, record_date, patient_id).Find(&inspection).Count(&itotal).Error
291 298
 	if itotal <= 0 {
292 299
 		inspection.PatientId = patient_id
293 300
 		inspection.OrgId = org_id
294
-		inspection.ProjectId = project_id
301
+		inspection.ProjectId = inspection_reference.ProjectId
295 302
 		inspection.ItemName = report.ItemName
296 303
 		inspection.ProjectName = Head.Item
297 304
 		inspection.InspectType = ItemType
298
-		inspection.ItemId = item_id
305
+		inspection.ItemId = inspection_reference.ItemId
299 306
 		inspection.InspectValue = report.Result
300 307
 		inspection.InspectDate = inspect_date
301 308
 		inspection.RecordDate = record_date
@@ -335,7 +342,7 @@ func LgthSync(Head *models.MiddleReportHandle, report ReportInfo, project_id int
335 342
 // 根据机构ID和检验检查小项名称获取该检查的item_id,如没有,则创建一个
336 343
 func GetItemID(org_id int64, project_name string, item_name string, project_id int64) (item_id int64, err error) {
337 344
 	var inspection_reference models.MiddleInspectionReference
338
-	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
345
+	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
339 346
 	if inspection_reference.ID > 0 {
340 347
 		return inspection_reference.ItemId, err
341 348
 	} else {
@@ -352,7 +359,7 @@ func GetItemID(org_id int64, project_name string, item_name string, project_id i
352 359
 // 根据机构ID和检验检查名称获取该检查的project_id,如没有,则创建一个
353 360
 func GetProjectID(org_id int64, project_name string) (project_id int64, err error) {
354 361
 	var inspection_reference models.MiddleInspectionReference
355
-	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project_name = ?", org_id, project_name).First(&inspection_reference).Error
362
+	err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and status = 1 and project = ? ", org_id, project_name).First(&inspection_reference).Error
356 363
 	if inspection_reference.ID > 0 {
357 364
 		return inspection_reference.ProjectId, err
358 365
 	} else {

+ 4 - 4
service/pljx_service.go View File

@@ -35,7 +35,7 @@ func GetPljxLisReport(rdb *gorm.DB, synctime string) (record []*pljxLisReportRes
35 35
 func SyncLisPljx(org_id int64) (err error) {
36 36
 	org := &models.DataUploadConfig{
37 37
 		OrgId:  org_id,
38
-		DbHost: "localhost",
38
+		DbHost: "(local)",
39 39
 		DbPort: "1433",
40 40
 		DbPass: "1Q2W3e4r!@#$",
41 41
 		DbUser: "kyy",
@@ -55,9 +55,9 @@ func SyncLisPljx(org_id int64) (err error) {
55 55
 	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)
56 56
 	var sync_time int64
57 57
 	if syncLastInfo.ID > 0 {
58
-		sync_time = syncLastInfo.SyncTime
58
+		sync_time = syncLastInfo.SyncTime - 60*60*24*7
59 59
 	} else {
60
-		sync_time = 1698768000 // 2023-01-01
60
+		sync_time = 1704038400 // 2024-01-01
61 61
 	}
62 62
 
63 63
 	SyncTime := time.Unix(sync_time, 0)
@@ -141,7 +141,7 @@ func SyncLisPljx(org_id int64) (err error) {
141 141
 					}
142 142
 				}
143 143
 				var itotal int
144
-				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
144
+				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
145 145
 				if itotal <= 0 {
146 146
 					// inspection.InspectValue = strings.Replace(LisInfo.Testresult, "&gt;", ">", -1)
147 147
 					// inspection.InspectValue = strings.Replace(LiLisInfo.Testresult, "&lt;", "<", -1)

+ 1 - 1
service/sclsyyyy_service.go View File

@@ -176,7 +176,7 @@ func SyncScyyyyLis() (err error) {
176 176
 				}
177 177
 			}
178 178
 			var itotal int
179
-			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, patientInfo.ID).Find(&inspection).Count(&itotal).Error
179
+			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, patientInfo.ID).Find(&inspection).Count(&itotal).Error
180 180
 			if itotal <= 0 {
181 181
 				// inspection.InspectValue = strings.Replace(LisInfo.Testresult, "&gt;", ">", -1)
182 182
 				// inspection.InspectValue = strings.Replace(LiLisInfo.Testresult, "&lt;", "<", -1)

+ 1 - 1
service/sssy_service.go View File

@@ -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
678
+	newtheTime := theTime.Unix() - 60*60*24*9
679 679
 
680 680
 	SyncTime := time.Unix(newtheTime, 0)
681 681
 	syncTimeStr := SyncTime.Format("2006-01-02")

+ 0 - 79
service/sy_service.go View File

@@ -87,57 +87,6 @@ func GetStsyItemID(org_id int64, project_name string, item_name string, project_
87 87
 	}
88 88
 }
89 89
 
90
-func SyncShuHeLis() (err error) {
91
-
92
-	org_id := int64(10644)
93
-	org := &models.DataUploadConfig{
94
-		OrgId:  org_id,
95
-		DbHost: "192.168.2.4",
96
-		DbPort: "1433",
97
-		DbPass: "a123456..",
98
-		DbUser: "sa",
99
-		DbName: "BI",
100
-	}
101
-
102
-	orgDb, err := CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
103
-	if err != nil {
104
-		utils.ErrorLog("创建数据库连接失败:%v", err)
105
-		return
106
-	}
107
-	fmt.Println(orgDb)
108
-
109
-	infoList, _ := GetHisLabelPrintStatusInfo(org_id)
110
-	if len(infoList) > 0 {
111
-		for _, item := range infoList {
112
-			p_ids_arr := strings.Split(item.Ids, ",")
113
-			list, _ := GetHisLabelPrintInfo(org_id, p_ids_arr)
114
-			fmt.Println("list==============", list)
115
-			patients, _ := GetPatientByIDOne(org_id, item.PatientId)
116
-			fmt.Println("patinets", patients.Name)
117
-			fmt.Println("patinets", patients.IdCardNo)
118
-			if len(list) > 0 {
119
-				for _, it := range list {
120
-					printCode := models.DataPrintCode{
121
-						HisUserId:   patients.IdCardNo,
122
-						Name:        patients.Name,
123
-						RecordDate:  it.RecordDate,
124
-						ProjectName: it.ProjectName,
125
-						Ctime:       time.Now().Unix(),
126
-						Mtime:       time.Now().Unix(),
127
-						Status:      1,
128
-						PrintId:     item.ID,
129
-						PatientId:   it.PatientId,
130
-					}
131
-					err = CratePrintCode(orgDb, printCode)
132
-					fmt.Println("errr-000000000000000", err)
133
-				}
134
-			}
135
-
136
-		}
137
-	}
138
-	return
139
-}
140
-
141 90
 // 汕头三优血液透析中心
142 91
 func SyncStsyLis() (err error) {
143 92
 	org_id := int64(10223)
@@ -332,31 +281,3 @@ func SyncToStsytx() {
332 281
 	// 第四步:关闭数据库连接
333 282
 	utils.SuccessLog("检验检查同步任务完成")
334 283
 }
335
-
336
-//舒和
337
-
338
-func CratePrintCode(rdb *gorm.DB, code models.DataPrintCode) error {
339
-
340
-	err := rdb.Create(&code).Error
341
-	return err
342
-}
343
-
344
-func GetHisLabelPrintStatusInfo(user_org_id int64) (info []*models.XtHisLabelPrintStatusInfo, err error) {
345
-
346
-	err = XTReadDB().Where("user_org_id = ? and status=1 and record_date ='2024-09-04'", user_org_id).Find(&info).Error
347
-
348
-	return info, err
349
-}
350
-
351
-func GetHisLabelPrintInfo(user_org_id int64, p_ids_arr []string) (list []*models.HisLabelPrintInfo, err error) {
352
-
353
-	err = XTReadDB().Where("user_org_id = ? and status=1 and id in(?)", user_org_id, p_ids_arr).Find(&list).Error
354
-
355
-	return list, err
356
-}
357
-func GetPatientByIDOne(orgID int64, patientID int64) (models.Patients, error) {
358
-	var patient models.Patients
359
-	err := readDb.Model(&models.Patients{}).Where("id = ? and user_org_id=? and status=1", patientID, orgID).First(&patient).Error
360
-
361
-	return patient, err
362
-}

+ 6 - 7
service/szwz_service.go View File

@@ -3,7 +3,6 @@ package service
3 3
 import (
4 4
 	"IC/models"
5 5
 	"IC/utils"
6
-	oracle "github.com/dzwvip/gorm-oracle"
7 6
 	"gorm.io/gorm"
8 7
 	"strings"
9 8
 	"time"
@@ -49,15 +48,15 @@ func GetSzwzyLisReportResule(rdb *gorm.DB, repno string) (record []*wzLisReportR
49 48
 }
50 49
 
51 50
 // 深圳五洲中医院Lis同步
52
-func SyncLisSzwz() (err error) {
51
+func SyncLisSzwz(orgDb *gorm.DB) (err error) {
53 52
 
54 53
 	org_id := int64(10580)
55 54
 
56
-	orgDb, err := gorm.Open(oracle.Open("oracle://BSLIS52:zhsoft@172.9.200.3:1521/JYK"), &gorm.Config{})
57
-
58
-	if err != nil {
59
-		utils.InfoLog("syncTimeStr:%v", err)
60
-	}
55
+	//orgDb, err := gorm.Open(oracle.Open("oracle://BSLIS52:zhsoft@172.9.200.3:1521/JYK"), &gorm.Config{})
56
+	//
57
+	//if err != nil {
58
+	//	utils.InfoLog("syncTimeStr:%v", err)
59
+	//}
61 60
 
62 61
 	// 第一步:获取上一次同步的时间点
63 62
 	syncLastInfo, _ := GetSyncTimeByOrgIDForYs(org_id)