Browse Source

合并代码

csx 4 years ago
parent
commit
f6b395b429
1 changed files with 25 additions and 15 deletions
  1. 25 15
      controllers/patient_api_controller.go

+ 25 - 15
controllers/patient_api_controller.go View File

@@ -7,6 +7,7 @@ import (
7 7
 	"XT_New/utils"
8 8
 	"encoding/json"
9 9
 	"log"
10
+	"math/rand"
10 11
 	"reflect"
11 12
 	"regexp"
12 13
 	"strconv"
@@ -3650,7 +3651,6 @@ func (c *PatientApiController) ExportPatients() {
3650 3651
 
3651 3652
 			if patientNameM["dialysis_no"] != nil || reflect.TypeOf(patientNameM["dialysis_no"]).String() == "string" {
3652 3653
 				dialysis_no, _ := patientNameM["dialysis_no"].(string)
3653
-
3654 3654
 				var tempPatient *models.Patients
3655 3655
 				for _, item := range all_patient {
3656 3656
 					if item.DialysisNo == dialysis_no {
@@ -3658,21 +3658,10 @@ func (c *PatientApiController) ExportPatients() {
3658 3658
 					}
3659 3659
 				}
3660 3660
 				if tempPatient != nil && tempPatient.ID > 0 {
3661
-					err_log := models.ExportErrLog{
3662
-						LogType:    1,
3663
-						UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
3664
-						ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的透析号在系统中已经存在",
3665
-						Status:     1,
3666
-						CreateTime: time.Now().Unix(),
3667
-						UpdateTime: time.Now().Unix(),
3668
-						ExportTime: export_time,
3669
-					}
3670
-					service.CreateExportErrLog(&err_log)
3671
-					continue
3661
+					patient.DialysisNo = GenerateDialysisNoTwo(patients)
3662
+				} else {
3663
+					patient.DialysisNo = dialysis_no
3672 3664
 				}
3673
-
3674
-				patient.DialysisNo = dialysis_no
3675
-
3676 3665
 			}
3677 3666
 
3678 3667
 			if patientNameM["height"] != nil || reflect.TypeOf(patientNameM["height"]).String() == "string" {
@@ -3806,3 +3795,24 @@ func (c *PatientApiController) GetMaxDialysisNo() {
3806 3795
 	})
3807 3796
 
3808 3797
 }
3798
+
3799
+func fab(n int) int {
3800
+	if n <= 1 {
3801
+		return 1
3802
+	}
3803
+	return fab(n-1) + fab(n-2)
3804
+}
3805
+
3806
+func GenerateDialysisNoTwo(patients []*models.Patients) string {
3807
+	dialysisNo2 := fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
3808
+	var tempPatient *models.Patients
3809
+	for _, item := range patients {
3810
+		if item.DialysisNo == dialysisNo2 {
3811
+			tempPatient = item
3812
+		}
3813
+	}
3814
+	if tempPatient == nil || tempPatient.ID == 0 {
3815
+		return dialysisNo2
3816
+	}
3817
+	return GenerateDialysisNoTwo(patients)
3818
+}