Преглед изворни кода

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

28169 пре 1 година
родитељ
комит
bdd5d26aab
2 измењених фајлова са 53 додато и 15 уклоњено
  1. 5 5
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  2. 48 10
      service/his_service.go

+ 5 - 5
controllers/new_mobile_api_controllers/mobile_his_api_controller.go Прегледај датотеку

691
 					tempPrescription.MedType = med_type
691
 					tempPrescription.MedType = med_type
692
 
692
 
693
 				}
693
 				}
694
-				service.SaveHisPrescription(tempPrescription)
694
+				service.SaveHisPrescriptionTwo(tempPrescription)
695
 
695
 
696
 				//更改患者挂号状态
696
 				//更改患者挂号状态
697
 				_, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.Org.Id)
697
 				_, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.Org.Id)
725
 								c.ServeFailJSONWithSGJErrorCode(errcode)
725
 								c.ServeFailJSONWithSGJErrorCode(errcode)
726
 								return
726
 								return
727
 							}
727
 							}
728
-							service.CreateHisDoctorAdvice(&s)
728
+							service.CreateHisDoctorAdviceTwo(&s)
729
 							redis := service.RedisClient()
729
 							redis := service.RedisClient()
730
 							key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
730
 							key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
731
 							fmt.Println("key111111111111111111", key)
731
 							fmt.Println("key111111111111111111", key)
741
 							tempTime := time.Unix(timestamp, 0)
741
 							tempTime := time.Unix(timestamp, 0)
742
 							timeFormat := tempTime.Format("20060102150405")
742
 							timeFormat := tempTime.Format("20060102150405")
743
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
743
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
744
-							service.CreateHisDoctorAdvice(&s)
744
+							service.CreateHisDoctorAdviceTwo(&s)
745
 
745
 
746
 							redis.Set(key, "", time.Second)
746
 							redis.Set(key, "", time.Second)
747
 							keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
747
 							keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
773
 								c.ServeFailJSONWithSGJErrorCode(errcode)
773
 								c.ServeFailJSONWithSGJErrorCode(errcode)
774
 								return
774
 								return
775
 							}
775
 							}
776
-							service.CreateHisProjectTwo(&p)
776
+							service.CreateHisProjectThree(&p)
777
 
777
 
778
 							var randNum int
778
 							var randNum int
779
 							randNum = rand.Intn(10000) + 1000
779
 							randNum = rand.Intn(10000) + 1000
781
 							tempTime := time.Unix(timestamp, 0)
781
 							tempTime := time.Unix(timestamp, 0)
782
 							timeFormat := tempTime.Format("20060102150405")
782
 							timeFormat := tempTime.Format("20060102150405")
783
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
783
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
784
-							service.SaveHisProjectTwo(&p)
784
+							service.CreateHisProjectThree(&p)
785
 
785
 
786
 							if p.Type == 3 { //处理透前准备耗材数量数据
786
 							if p.Type == 3 { //处理透前准备耗材数量数据
787
 								consumables, _ := service.FindHisConsumablesByID(adminInfo.Org.Id, patient_id, recordDateTime, p.ProjectId)
787
 								consumables, _ := service.FindHisConsumablesByID(adminInfo.Org.Id, patient_id, recordDateTime, p.ProjectId)

+ 48 - 10
service/his_service.go Прегледај датотеку

402
 	return err
402
 	return err
403
 }
403
 }
404
 
404
 
405
-func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
406
-	tx := writeDb.Begin()
407
-
405
+func SaveHisPrescription(tx *gorm.DB, prescription *models.HisPrescription) (err error) {
408
 	if err = tx.Model(&models.HisPrescription{}).Save(prescription).Error; err != nil {
406
 	if err = tx.Model(&models.HisPrescription{}).Save(prescription).Error; err != nil {
409
 		tx.Rollback()
407
 		tx.Rollback()
410
 		return
408
 		return
413
 	return
411
 	return
414
 }
412
 }
415
 
413
 
414
+func SaveHisPrescriptionTwo(prescription *models.HisPrescription) (err error) {
415
+
416
+	err = writeDb.Model(&models.HisPrescription{}).Save(prescription).Error
417
+	return
418
+}
419
+
416
 func DelelteHisPrescription(id int64, user_org_id int64) (err error) {
420
 func DelelteHisPrescription(id int64, user_org_id int64) (err error) {
417
 	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
421
 	err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
418
 	err = writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
422
 	err = writeDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND prescription_id = ?", user_org_id, id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
881
 	return
885
 	return
882
 }
886
 }
883
 
887
 
884
-func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
888
+func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
889
+	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
890
+		tx.Rollback()
891
+		return
892
+	}
893
+	tx.Commit()
885
 
894
 
895
+	return
896
+}
897
+
898
+func CreateHisDoctorAdviceTwo(s *models.HisDoctorAdviceInfo) (err error) {
886
 	tx := writeDb.Begin()
899
 	tx := writeDb.Begin()
887
 	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
900
 	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
888
 		tx.Rollback()
901
 		tx.Rollback()
893
 	return
906
 	return
894
 }
907
 }
895
 
908
 
896
-func CreateHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
909
+func CreateHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
910
+	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
911
+		tx.Rollback()
912
+		return
913
+	}
914
+	tx.Commit()
915
+
916
+	return
917
+}
918
+
919
+func CreateHisProjectThree(project *models.HisPrescriptionProject) (err error) {
897
 	tx := writeDb.Begin()
920
 	tx := writeDb.Begin()
898
 	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
921
 	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
899
 		tx.Rollback()
922
 		tx.Rollback()
904
 	return
927
 	return
905
 }
928
 }
906
 
929
 
907
-func SaveHisProjectTwo(project *models.HisPrescriptionProject) (err error) {
908
-	err = writeDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
930
+func SaveHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
931
+	//err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error
932
+	if err = tx.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND id = ?", project.UserOrgId, project.ID).Updates(map[string]interface{}{"feedetl_sn": project.FeedetlSn, "mtime": time.Now().Unix()}).Error; err != nil {
933
+		tx.Rollback()
934
+		return
935
+	}
936
+	tx.Commit()
937
+
909
 	return
938
 	return
910
 }
939
 }
911
 
940
 
2593
 	writeDb.Model(&models.HisLabelPrintInfo{}).Where("p_project_id = ?", id).Updates(map[string]interface{}{"status": 0})
2622
 	writeDb.Model(&models.HisLabelPrintInfo{}).Where("p_project_id = ?", id).Updates(map[string]interface{}{"status": 0})
2594
 }
2623
 }
2595
 
2624
 
2596
-func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2597
-	err := writeDb.Save(&label).Error
2598
-	return err
2625
+func CreateHisLabelRecord(label *models.HisLabelPrintInfo, tx *gorm.DB) (err error) {
2626
+	if err = tx.Save(&label).Error; err != nil {
2627
+		tx.Rollback()
2628
+		return
2629
+	}
2630
+	tx.Commit()
2631
+	return
2632
+}
2633
+
2634
+func CreateHisLabelRecordTwo(label *models.HisLabelPrintInfo) (err error) {
2635
+	err = writeDb.Save(&label).Error
2636
+	return
2599
 }
2637
 }
2600
 
2638
 
2601
 func DeletePsnNCDSRecordById(id int64) (err error) {
2639
 func DeletePsnNCDSRecordById(id int64) (err error) {