28169 il y a 2 mois
Parent
révision
cb762bb24d
6 fichiers modifiés avec 185 ajouts et 29 suppressions
  1. 14 6
      controllers/lis.go
  2. 65 0
      models/report_result.go
  3. 2 0
      routers/router.go
  4. 15 15
      service/cron.go
  5. 5 4
      service/lis_service.go
  6. 84 4
      service/sy_service.go

+ 14 - 6
controllers/lis.go Voir le fichier

@@ -1,18 +1,19 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"IC/enums"
5
-	"IC/models"
6
-	"IC/service"
7
-	"IC/utils"
8 4
 	"encoding/json"
9 5
 	"fmt"
10
-	_ "github.com/astaxie/beego"
11
-	_ "github.com/jinzhu/gorm"
12 6
 	"net"
13 7
 	_ "strconv"
14 8
 	"strings"
15 9
 	"time"
10
+
11
+	"IC/enums"
12
+	"IC/models"
13
+	"IC/service"
14
+	"IC/utils"
15
+	_ "github.com/astaxie/beego"
16
+	_ "github.com/jinzhu/gorm"
16 17
 )
17 18
 
18 19
 // LisController operations for Lis
@@ -602,3 +603,10 @@ func (c *LisController) SyncCsnyLis() {
602 603
 		"resultList": "同步成功",
603 604
 	})
604 605
 }
606
+
607
+func (c *LisController) TestList() {
608
+	service.SyncShuHeLis()
609
+	c.ServeSuccessJSON(map[string]interface{}{
610
+		"resultList": "同步成功",
611
+	})
612
+}

+ 65 - 0
models/report_result.go Voir le fichier

@@ -53,3 +53,68 @@ type InspectResult struct {
53 53
 	intFlag        int    `json:"intFlag"`
54 54
 	ListResult     GPReportListResultData
55 55
 }
56
+
57
+type DataPrintCode struct {
58
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
59
+	HisUserId   string `gorm:"column:his_user_id" json:"his_user_id" form:"his_user_id"`
60
+	Name        string `gorm:"column:name" json:"name" form:"name"`
61
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
62
+	ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
63
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
64
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
65
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
66
+	PrintId     int64  `gorm:"column:print_id" json:"print_id" form:"print_id"`
67
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
68
+}
69
+
70
+func (DataPrintCode) TableName() string {
71
+	return "print_code"
72
+}
73
+
74
+type XtHisLabelPrintStatusInfo struct {
75
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
76
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
77
+	Ctime              int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
78
+	Mtime              int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
79
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
80
+	IsCombinationPrint int64  `gorm:"column:is_combination_print" json:"is_combination_print" form:"is_combination_print"`
81
+	RecordDate         string `gorm:"column:record_date" json:"record_date" form:"record_date"`
82
+	ItemIds            string `gorm:"column:item_ids" json:"item_ids" form:"item_ids"`
83
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
84
+	ProjectIds         string `gorm:"column:project_ids" json:"project_ids" form:"project_ids"`
85
+	DoctorId           int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
86
+	Ids                string `gorm:"column:ids" json:"ids" form:"ids"`
87
+	IsTeam             int64  `gorm:"column:is_team" json:"is_team" form:"is_team"`
88
+	IsPrint            int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
89
+	ApplyCode          string `gorm:"column:apply_code" json:"apply_code" form:"apply_code"`
90
+}
91
+
92
+func (XtHisLabelPrintStatusInfo) TableName() string {
93
+	return "his_label_print_status_info"
94
+}
95
+
96
+type HisLabelPrintInfo struct {
97
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
98
+	PatientId      int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
99
+	Number         string `gorm:"column:number" json:"number" form:"number"`
100
+	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
101
+	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
102
+	DoctorId       int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
103
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
104
+	ProjectName    string `gorm:"column:project_name" json:"project_name" form:"project_name"`
105
+	ProjectId      int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
106
+	IsPrint        int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
107
+	RecordDate     int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
108
+	ItemId         int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
109
+	PProjectId     int64  `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
110
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
111
+	DoctorName     string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
112
+	PatientName    string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
113
+	FeedetlSn      string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
114
+	PrescriptionId int64  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
115
+	ApplyCode      string `gorm:"column:apply_code" json:"apply_code" form:"apply_code"`
116
+}
117
+
118
+func (HisLabelPrintInfo) TableName() string {
119
+	return "his_label_print_info"
120
+}

+ 2 - 0
routers/router.go Voir le fichier

@@ -51,4 +51,6 @@ func init() {
51 51
 	//beego.Router("/api/lis/synczhra", &controllers.LisController{}, "get:SyncZhraLis")
52 52
 	beego.Router("/api/lis/syncchyd", &controllers.LisController{}, "get:SyncChydLis")
53 53
 	beego.Router("/test", &controllers.LisController{}, "get:Test")
54
+
55
+	beego.Router("/testlist", &controllers.LisController{}, "get:TestList")
54 56
 }

+ 15 - 15
service/cron.go Voir le fichier

@@ -1,14 +1,14 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"IC/models"
5
-	"IC/utils"
6 4
 	"encoding/json"
7 5
 	_ "fmt"
8
-	_ "github.com/jinzhu/gorm"
9
-	"github.com/robfig/cron/v3"
10 6
 	_ "strings"
11 7
 	"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
 	//
@@ -80,10 +80,10 @@ func BeginAutoSyncLis() {
80 80
 	//	SyncLisSzwz()
81 81
 	//})
82 82
 
83
-	spec8 := "0 25 */3 * * ?" // 每个小时同步一次 汕头三优透析中心LIS对接,本地部署的
84
-	createLisSyncCronJob.AddFunc(spec8, func() {
85
-		SyncStsyLis()
86
-	})
83
+	//spec8 := "0 25 */3 * * ?" // 每个小时同步一次 汕头三优透析中心LIS对接,本地部署的
84
+	//createLisSyncCronJob.AddFunc(spec8, func() {
85
+	SyncStsyLis()
86
+	//})
87 87
 
88 88
 	//spec9 := "0 57 * * * ?" // 每个小时同步一次 遵化仁爱医院LIS对接,本地部署的
89 89
 	//createLisSyncCronJob.AddFunc(spec9, func() {
@@ -150,7 +150,7 @@ func BeginAutoSyncLis() {
150 150
 	//	SyncBjncHis()
151 151
 	//})
152 152
 
153
-	createLisSyncCronJob.Start()
153
+	//createLisSyncCronJob.Start()
154 154
 }
155 155
 
156 156
 func AutoSyncLis() {

+ 5 - 4
service/lis_service.go Voir le fichier

@@ -1,14 +1,15 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"IC/models"
5
-	"IC/utils"
6
-	_ "IC/utils"
7 4
 	_ "fmt"
8
-	_ "github.com/jinzhu/gorm"
9 5
 	_ "strconv"
10 6
 	"strings"
11 7
 	"time"
8
+
9
+	"IC/models"
10
+	"IC/utils"
11
+	_ "IC/utils"
12
+	_ "github.com/jinzhu/gorm"
12 13
 )
13 14
 
14 15
 // 获取备份库所有的医嘱信息

+ 84 - 4
service/sy_service.go Voir le fichier

@@ -2,16 +2,17 @@ package service
2 2
 
3 3
 // 三优 检验检查对接
4 4
 import (
5
-	"IC/models"
6
-	"IC/utils"
7 5
 	_ "encoding/json"
8 6
 	_ "encoding/xml"
9 7
 	"fmt"
10
-	"github.com/jinzhu/gorm"
11
-	_ "github.com/jinzhu/gorm"
12 8
 	_ "strconv"
13 9
 	"strings"
14 10
 	"time"
11
+
12
+	"IC/models"
13
+	"IC/utils"
14
+	"github.com/jinzhu/gorm"
15
+	_ "github.com/jinzhu/gorm"
15 16
 )
16 17
 
17 18
 type stsylis struct {
@@ -86,6 +87,57 @@ func GetStsyItemID(org_id int64, project_name string, item_name string, project_
86 87
 	}
87 88
 }
88 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
+
89 141
 // 汕头三优血液透析中心
90 142
 func SyncStsyLis() (err error) {
91 143
 	org_id := int64(10223)
@@ -280,3 +332,31 @@ func SyncToStsytx() {
280 332
 	// 第四步:关闭数据库连接
281 333
 	utils.SuccessLog("检验检查同步任务完成")
282 334
 }
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", 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
+}