XMLWAN 3 years ago
parent
commit
2f6861a8f5

+ 74 - 4
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -7,6 +7,7 @@ import (
7 7
 	"XT_New/service"
8 8
 	"encoding/json"
9 9
 	"fmt"
10
+	"strconv"
10 11
 	"time"
11 12
 )
12 13
 
@@ -28,7 +29,6 @@ func (this *CommonApiController) GetInspectionMajor() {
28 29
 
29 30
 func (this *CommonApiController) GetInspectionMinor() {
30 31
 	id, _ := this.GetInt64("id")
31
-	fmt.Println("id----------------------------------------", id)
32 32
 	minor, err := service.GetInspectionMinor(id)
33 33
 	if err != nil {
34 34
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -55,8 +55,6 @@ func (this *CommonApiController) GetInspectionRange() {
55 55
 func (this *CommonApiController) SaveConfiguration() {
56 56
 	adminInfo := this.GetAdminUserInfo()
57 57
 	orgid := adminInfo.CurrentOrgId
58
-	fmt.Println(orgid)
59
-	fmt.Println("触发-------------------0")
60 58
 	dataBody := make(map[string]interface{}, 0)
61 59
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
62 60
 	fmt.Println("err", err)
@@ -69,13 +67,14 @@ func (this *CommonApiController) SaveConfiguration() {
69 67
 	largerange := dataBody["large_range"].(string)
70 68
 	fmt.Println("largerange", largerange)
71 69
 	sort := dataBody["sort"].(string)
70
+	sorts, err := strconv.ParseInt(sort, 10, 64)
72 71
 	fmt.Println("sort", sort)
73 72
 	standard := models.XtQualityControlStandard{
74 73
 		InspectionMajor: inspectionmajor,
75 74
 		InspectionMinor: inspectionMinor,
76 75
 		MinRange:        minrange,
77 76
 		LargeRange:      largerange,
78
-		Sort:            sort,
77
+		Sort:            sorts,
79 78
 		UserOrgId:       orgid,
80 79
 		Status:          1,
81 80
 		CreatedTime:     time.Now().Unix(),
@@ -106,3 +105,74 @@ func (this *CommonApiController) GetConfigurationlist() {
106 105
 		"total":             total,
107 106
 	})
108 107
 }
108
+
109
+func (this *CommonApiController) GetConfigurationDetail() {
110
+	id, _ := this.GetInt64("id")
111
+	fmt.Println("id是", id)
112
+	detail, err := service.GetConfigurationDetail(id)
113
+	if err != nil {
114
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
115
+		return
116
+	}
117
+	this.ServeSuccessJSON(map[string]interface{}{
118
+		"configurationdetail": detail,
119
+	})
120
+}
121
+
122
+func (this *CommonApiController) GetAllInspectionminor() {
123
+
124
+	minor, err := service.GetAllInspectionMinor(0)
125
+	if err != nil {
126
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
127
+		return
128
+	}
129
+	this.ServeSuccessJSON(map[string]interface{}{
130
+		"minor": minor,
131
+	})
132
+}
133
+
134
+func (this *CommonApiController) UpdateConfiguration() {
135
+	id, _ := this.GetInt64("id")
136
+	fmt.Println("id", id)
137
+	dataBody := make(map[string]interface{}, 0)
138
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
139
+	fmt.Println("err", err)
140
+	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
141
+	fmt.Println("大项", inspectionmajor)
142
+	inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
143
+	fmt.Println("小项", inspectionMinor)
144
+	minrange := dataBody["min_range"].(string)
145
+	fmt.Println("minragne", minrange)
146
+	largerange := dataBody["large_range"].(string)
147
+	fmt.Println("largerange", largerange)
148
+	sort := int64(dataBody["sort"].(float64))
149
+
150
+	standard := models.XtQualityControlStandard{
151
+		InspectionMajor: inspectionmajor,
152
+		InspectionMinor: inspectionMinor,
153
+		MinRange:        minrange,
154
+		LargeRange:      largerange,
155
+		Sort:            sort,
156
+	}
157
+	err = service.UpdarteConfiguration(&standard, id)
158
+	if err != nil {
159
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
160
+		return
161
+	}
162
+	this.ServeSuccessJSON(map[string]interface{}{
163
+		"standard": standard,
164
+	})
165
+}
166
+
167
+func (this *CommonApiController) DeleteConfiguration() {
168
+	id, _ := this.GetInt64("id")
169
+	err := service.DeleteConfiguration(id)
170
+	if err != nil {
171
+		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
172
+		return
173
+	}
174
+	returnData := make(map[string]interface{}, 0)
175
+	returnData["msg"] = "ok"
176
+	this.ServeSuccessJSON(returnData)
177
+	return
178
+}

+ 4 - 0
controllers/new_mobile_api_controllers/common_api_router.go View File

@@ -11,4 +11,8 @@ func CommonApiControllersRegisterRouters() {
11 11
 	beego.Router("/com/api/getinspectionrange", &CommonApiController{}, "Get:GetInspectionRange")
12 12
 	beego.Router("/com/api/saveconfiguration", &CommonApiController{}, "Post:SaveConfiguration")
13 13
 	beego.Router("com/api/getconfigurationlist", &CommonApiController{}, "Get:GetConfigurationlist")
14
+	beego.Router("com/api/getconfigurationdetail", &CommonApiController{}, "Get:GetConfigurationDetail")
15
+	beego.Router("com/api/getallinspectionminor", &CommonApiController{}, "Get:GetAllInspectionminor")
16
+	beego.Router("com/api/updateconfiguration", &CommonApiController{}, "Post:UpdateConfiguration")
17
+	beego.Router("com/api/deleteconfiguration", &CommonApiController{}, "Delete:DeleteConfiguration")
14 18
 }

+ 2 - 2
models/common_models.go View File

@@ -5,7 +5,7 @@ type QualityControlStandard struct {
5 5
 	InspectionMajor int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
6 6
 	InspectionMinor int64  `gorm:"column:inspection_minor" json:"inspection_minor" form:"inspection_minor"`
7 7
 	MinRange        string `gorm:"column:min_range" json:"min_range" form:"min_range"`
8
-	Sort            string `gorm:"column:sort" json:"sort" form:"sort"`
8
+	Sort            int64  `gorm:"column:sort" json:"sort" form:"sort"`
9 9
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
10 10
 	Status          int64  `gorm:"column:status" json:"status" form:"status"`
11 11
 	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
@@ -21,7 +21,7 @@ type XtQualityControlStandard struct {
21 21
 	InspectionMajor int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
22 22
 	InspectionMinor int64  `gorm:"column:inspection_minor" json:"inspection_minor" form:"inspection_minor"`
23 23
 	MinRange        string `gorm:"column:min_range" json:"min_range" form:"min_range"`
24
-	Sort            string `gorm:"column:sort" json:"sort" form:"sort"`
24
+	Sort            int64  `gorm:"column:sort" json:"sort" form:"sort"`
25 25
 	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
26 26
 	Status          int64  `gorm:"column:status" json:"status" form:"status"`
27 27
 	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`

+ 26 - 4
service/common_service.go View File

@@ -3,6 +3,7 @@ package service
3 3
 import (
4 4
 	"XT_New/models"
5 5
 	"fmt"
6
+	"time"
6 7
 )
7 8
 
8 9
 func GetInspectionMajor(orgid int64) (inspection []*models.XtInspectionReference, err error) {
@@ -31,9 +32,6 @@ func SaveInspection(standard *models.XtQualityControlStandard) error {
31 32
 
32 33
 func GetConfigurationlist(orgid int64, limit int64, page int64) (standard []*models.QualityControlStandard, total int64, err error) {
33 34
 
34
-	//err = XTReadDB().Model(&standard).Where("user_org_id = ? and status =1", orgid).Order("sort asc,created_time desc").Find(&standard).Error
35
-	//return standard,err
36
-
37 35
 	db := XTReadDB().Table("xt_quality_control_standard as x").Where("x.status =1")
38 36
 	if orgid > 0 {
39 37
 		db = db.Where("x.user_org_id = ?", orgid)
@@ -41,7 +39,31 @@ func GetConfigurationlist(orgid int64, limit int64, page int64) (standard []*mod
41 39
 	table := XTReadDB().Table("xt_inspection_reference as s")
42 40
 	fmt.Println(table)
43 41
 	offset := (page - 1) * limit
44
-	err = db.Order("x.sort asc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,s.unit,s.project_name,s.item_name").Count(&total).
42
+	err = db.Order("x.sort asc,x.created_time desc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,s.unit,s.project_name,s.item_name").Count(&total).
45 43
 		Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
46 44
 	return standard, total, err
47 45
 }
46
+
47
+func GetConfigurationDetail(id int64) (models.XtQualityControlStandard, error) {
48
+	standard := models.XtQualityControlStandard{}
49
+	err := XTReadDB().Model(&standard).Where("id=? and status = 1", id).Find(&standard).Error
50
+	return standard, err
51
+}
52
+
53
+func GetAllInspectionMinor(orgid int64) (standard []*models.XtInspectionReference, err error) {
54
+
55
+	err = XTReadDB().Model(&standard).Where("org_id = ? and status = 1", orgid).Find(&standard).Error
56
+	return standard, err
57
+}
58
+
59
+func UpdarteConfiguration(st *models.XtQualityControlStandard, id int64) error {
60
+
61
+	err := XTWriteDB().Model(&st).Where("id = ?", id).Updates(map[string]interface{}{"inspection_major": st.InspectionMajor, "inspection_minor": st.InspectionMinor, "min_range": st.MinRange, "large_range": st.LargeRange, "sort": st.Sort, "updated_time": time.Now().Unix()}).Error
62
+	return err
63
+}
64
+
65
+func DeleteConfiguration(id int64) (err error) {
66
+
67
+	err = XTWriteDB().Model(models.XtQualityControlStandard{}).Where("id=?", id).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
68
+	return err
69
+}

+ 25 - 0
service/patient_service.go View File

@@ -1267,6 +1267,31 @@ func CreateExportPatient(patient *models.Patients, contagions []int64, org_creat
1267 1267
 			return
1268 1268
 		}
1269 1269
 	}
1270
+	patientsNew := models.XtPatientsNew{
1271
+		Name:              patient.Name,
1272
+		Gender:            patient.Gender,
1273
+		Phone:             patient.Phone,
1274
+		IdCardNo:          patient.IdCardNo,
1275
+		FirstDialysisDate: patient.FirstDialysisDate,
1276
+		Source:            patient.Source,
1277
+		Lapseto:           patient.Lapseto,
1278
+		IsInfectious:      patient.IsInfectious,
1279
+		DialysisNo:        patient.DialysisNo,
1280
+		Height:            patient.Height,
1281
+		HomeAddress:       patient.HomeAddress,
1282
+		IsExcelExport:     1,
1283
+		BloodPatients:     1,
1284
+		Status:            1,
1285
+		CreatedTime:       time.Now().Unix(),
1286
+		UserOrgId:         patient.UserOrgId,
1287
+		BloodId:           patient.ID,
1288
+	}
1289
+	err = utx.Create(&patientsNew).Error
1290
+	if err != nil {
1291
+		utx.Rollback()
1292
+		btx.Rollback()
1293
+		return
1294
+	}
1270 1295
 	utx.Commit()
1271 1296
 	btx.Commit()
1272 1297