Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

28169 1 year ago
parent
commit
0340e65f58
2 changed files with 34 additions and 10 deletions
  1. 32 9
      controllers/his_api_controller.go
  2. 2 1
      models/his_models.go

+ 32 - 9
controllers/his_api_controller.go View File

3487
 								var p models.HisPrescriptionProject
3487
 								var p models.HisPrescriptionProject
3488
 								p.PrescriptionId = tempPrescription.ID
3488
 								p.PrescriptionId = tempPrescription.ID
3489
 								p.Ctime = time.Now().Unix()
3489
 								p.Ctime = time.Now().Unix()
3490
-								p.Mtime = time.Now().Unix()
3490
+								p.Mtime = p.Ctime
3491
 								p.PatientId = patient_id
3491
 								p.PatientId = patient_id
3492
 								p.RecordDate = theTime3.Unix()
3492
 								p.RecordDate = theTime3.Unix()
3493
 								p.Doctor = doctor_id
3493
 								p.Doctor = doctor_id
4116
 			return
4116
 			return
4117
 		}
4117
 		}
4118
 	} else {
4118
 	} else {
4119
+		// 开始主事务
4120
+		db := service.XTWriteDB()
4121
+		tx := db.Begin()
4122
+
4123
+		// 在函数结束时处理事务回滚
4124
+		defer func() {
4125
+			if r := recover(); r != nil {
4126
+				tx.Rollback()
4127
+			}
4128
+		}()
4119
 
4129
 
4120
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
4130
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
4121
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
4131
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
7438
 			hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
7448
 			hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
7439
 			if err == nil {
7449
 			if err == nil {
7440
 				if hisAdvice.ID > 0 {
7450
 				if hisAdvice.ID > 0 {
7441
-
7451
+					if hisAdvice.YbSyncStatus == 1 {
7452
+						advice.YbSyncStatus = 0
7453
+					}
7454
+					advice.UpdatedTime = time.Now().Unix()
7455
+					advice.CreatedTime = hisAdvice.CreatedTime
7442
 					advice.ExecutionTime = hisAdvice.ExecutionTime
7456
 					advice.ExecutionTime = hisAdvice.ExecutionTime
7443
 					advice.ExecutionStaff = hisAdvice.ExecutionStaff
7457
 					advice.ExecutionStaff = hisAdvice.ExecutionStaff
7444
 					advice.ExecutionState = hisAdvice.ExecutionState
7458
 					advice.ExecutionState = hisAdvice.ExecutionState
7609
 		id := int64(json["id"].(float64))
7623
 		id := int64(json["id"].(float64))
7610
 		project.ID = id
7624
 		project.ID = id
7611
 		temp_project, _ := service.GetHisPrescriptionProjectByID(id)
7625
 		temp_project, _ := service.GetHisPrescriptionProjectByID(id)
7612
-		project.ExecutionStaff = temp_project.ExecutionStaff
7613
-		project.ExecutionState = temp_project.ExecutionState
7614
-		project.ExecutionTime = temp_project.ExecutionTime
7615
-		project.Checker = temp_project.Checker
7616
-		project.CheckState = temp_project.CheckState
7617
-		project.CheckTime = temp_project.CheckTime
7618
-		project.TeamId = temp_project.TeamId
7626
+		if temp_project.ID > 0 {
7627
+			if temp_project.YbSyncStatus == 1 {
7628
+				project.YbSyncStatus = 0
7629
+			}
7630
+			project.ExecutionStaff = temp_project.ExecutionStaff
7631
+			project.ExecutionState = temp_project.ExecutionState
7632
+			project.ExecutionTime = temp_project.ExecutionTime
7633
+			project.Checker = temp_project.Checker
7634
+			project.CheckState = temp_project.CheckState
7635
+			project.CheckTime = temp_project.CheckTime
7636
+			project.TeamId = temp_project.TeamId
7637
+			project.Ctime = temp_project.Ctime
7638
+			project.Mtime = time.Now().Unix()
7639
+
7640
+		}
7641
+
7619
 	}
7642
 	}
7620
 	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
7643
 	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
7621
 		types := int64(json["type"].(float64))
7644
 		types := int64(json["type"].(float64))

+ 2 - 1
models/his_models.go View File

271
 	IsMobile              int64                  `gorm:"column:is_mobile" json:"is_mobile" form:"is_mobile"`
271
 	IsMobile              int64                  `gorm:"column:is_mobile" json:"is_mobile" form:"is_mobile"`
272
 	IsSelfDrug            int64                  `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
272
 	IsSelfDrug            int64                  `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
273
 	DrugWayCount          string                 `gorm:"column:drug_way_count" json:"drug_way_count" form:"drug_way_count"`
273
 	DrugWayCount          string                 `gorm:"column:drug_way_count" json:"drug_way_count" form:"drug_way_count"`
274
+	YbSyncStatus          int64                  `gorm:"column:yb_sync_status" json:"yb_sync_status" form:"yb_sync_status"`
274
 }
275
 }
275
 
276
 
276
 func (HisDoctorAdviceInfo) TableName() string {
277
 func (HisDoctorAdviceInfo) TableName() string {
889
 	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
890
 	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
890
 	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
891
 	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
891
 	IsOut                int64        `gorm:"column:is_out" json:"is_out" form:"is_out"` //新增字段
892
 	IsOut                int64        `gorm:"column:is_out" json:"is_out" form:"is_out"` //新增字段
892
-
893
+	YbSyncStatus         int64        `gorm:"column:yb_sync_status" json:"yb_sync_status" form:"yb_sync_status"`
893
 }
894
 }
894
 
895
 
895
 func (HisPrescriptionProject) TableName() string {
896
 func (HisPrescriptionProject) TableName() string {