XMLWAN 4 years ago
parent
commit
a9fce10d45

+ 40 - 1
controllers/manage_api_controller.go View File

@@ -92,6 +92,9 @@ func ManageRouters() {
92 92
 	beego.Router("/api/manage/selectbed", &MachineApiController{}, "get:SelectBed")
93 93
 	beego.Router("/api/manage/getime", &MachineApiController{}, "get:GetTimeData")
94 94
 	beego.Router("/api/manage/deleteimages", &MachineApiController{}, "delete:DeleteImages")
95
+	beego.Router("/api/manage/getusermachtotalcount", &MachineApiController{}, "Get:GetUserMachTotalCount")
96
+	beego.Router("/api/manage/getusertotalcount", &MachineApiController{}, "Get:GetUserTotalCount")
97
+
95 98
 }
96 99
 
97 100
 func (this *MachineApiController) SaveManageInfo() {
@@ -2210,10 +2213,15 @@ func (this *MachineApiController) GetRepair() {
2210 2213
 }
2211 2214
 
2212 2215
 func (this *MachineApiController) EditUser() {
2216
+	adminUser := this.GetAdminUserInfo()
2217
+	orgId := adminUser.CurrentOrgId
2213 2218
 	id, _ := this.GetInt64("id")
2214 2219
 	fmt.Println("id", id)
2215 2220
 	patientid, _ := this.GetInt64("patientid")
2216 2221
 	device, err := service.GetUserInformation(id)
2222
+	//获取初次使用记录
2223
+	macher, err := service.GetUserTotalByMacher(device.EquimentId)
2224
+	count, err := service.GetUserTotalCount(orgId, device.BedNumber)
2217 2225
 	patients, err := service.GetPatientInfoMation(patientid)
2218 2226
 	if err != nil {
2219 2227
 		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
@@ -2222,6 +2230,8 @@ func (this *MachineApiController) EditUser() {
2222 2230
 	this.ServeSuccessJSON(map[string]interface{}{
2223 2231
 		"device":   device,
2224 2232
 		"patients": patients,
2233
+		"count":    count,
2234
+		"macher":   macher,
2225 2235
 	})
2226 2236
 }
2227 2237
 
@@ -3067,7 +3077,7 @@ func (this *MachineApiController) GetTimeData() {
3067 3077
 func (this *MachineApiController) DeleteImages() {
3068 3078
 	id, _ := this.GetInt64("id")
3069 3079
 	err := service.DeleteImages(id)
3070
-	fmt.Print("err========", err)
3080
+	fmt.Print("err", err)
3071 3081
 	if err != nil {
3072 3082
 		this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
3073 3083
 		return
@@ -3077,3 +3087,32 @@ func (this *MachineApiController) DeleteImages() {
3077 3087
 	this.ServeSuccessJSON(returnData)
3078 3088
 	return
3079 3089
 }
3090
+
3091
+func (this *MachineApiController) GetUserMachTotalCount() {
3092
+	adminUserInfo := this.GetAdminUserInfo()
3093
+	orgid := adminUserInfo.CurrentOrgId
3094
+	count, err := service.GetUserMachTotalCount(orgid)
3095
+	if err != nil {
3096
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
3097
+		return
3098
+	}
3099
+	this.ServeSuccessJSON(map[string]interface{}{
3100
+		"count": count,
3101
+	})
3102
+}
3103
+
3104
+func (this *MachineApiController) GetUserTotalCount() {
3105
+	adminUserInfo := this.GetAdminUserInfo()
3106
+	orgid := adminUserInfo.CurrentOrgId
3107
+	id, _ := this.GetInt64("id")
3108
+	count, err := service.GetUserTotalCount(orgid, id)
3109
+	addmacher, err := service.GetUserTotal(orgid, id)
3110
+	if err != nil {
3111
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
3112
+		return
3113
+	}
3114
+	this.ServeSuccessJSON(map[string]interface{}{
3115
+		"count":     count,
3116
+		"addmacher": addmacher,
3117
+	})
3118
+}

+ 177 - 0
controllers/new_mobile_api_controllers/new_manage_api_controller.go View File

@@ -0,0 +1,177 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/controllers/mobile_api_controllers"
5
+	"XT_New/enums"
6
+	"XT_New/models"
7
+	"XT_New/service"
8
+	"XT_New/utils"
9
+	"fmt"
10
+	"github.com/jinzhu/gorm"
11
+	"strconv"
12
+	"time"
13
+)
14
+
15
+type NewManageApiController struct {
16
+	mobile_api_controllers.MobileBaseAPIAuthController
17
+}
18
+
19
+func (this *NewManageApiController) GetEquitAutoInfo() {
20
+
21
+	adminUser := this.GetMobileAdminUserInfo()
22
+	orgid := adminUser.Org.Id
23
+	remander, err := service.GetRemanderData(orgid)
24
+	if err != nil {
25
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
26
+		return
27
+	}
28
+	this.ServeSuccessJSON(map[string]interface{}{
29
+		"remander": remander,
30
+	})
31
+}
32
+
33
+func (this *NewManageApiController) GetDisInfectionTime() {
34
+	adminUser := this.GetMobileAdminUserInfo()
35
+	orgid := adminUser.Org.Id
36
+	bedid, _ := this.GetInt64("bed_id")
37
+	scheduletype, _ := this.GetInt64("schedule_type")
38
+	scheduleweek, _ := this.GetInt64("schedule_week")
39
+	fmt.Println(scheduleweek)
40
+	//查询改设备是否有消毒计划
41
+	plan, err := service.GetDisInfectionTime(orgid, bedid, scheduletype, scheduleweek)
42
+	if err == gorm.ErrRecordNotFound {
43
+		//去查询使用登记最后一条数据
44
+		infomation, err := service.GetLaseDeviceInfomation(orgid, bedid)
45
+		if err != nil {
46
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
47
+			return
48
+		}
49
+		this.ServeSuccessJSON(map[string]interface{}{
50
+			"plan": infomation.LongTime,
51
+		})
52
+	} else if err == nil {
53
+		if err != nil {
54
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
55
+			return
56
+		}
57
+		this.ServeSuccessJSON(map[string]interface{}{
58
+			"plan": plan.DisinfecTime,
59
+		})
60
+	} else {
61
+
62
+	}
63
+
64
+}
65
+
66
+func (this *NewManageApiController) SaveDisInfectionInfo() {
67
+	adminUser := this.GetMobileAdminUserInfo()
68
+	orgid := adminUser.Org.Id
69
+	bedid, _ := this.GetInt64("bed_id")
70
+	start_time := this.GetString("start_time")
71
+	startdate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_time)
72
+	startdateunix := startdate.Unix()
73
+	disinfectime, _ := this.GetInt64("disinfec_time")
74
+	endtime := this.GetString("end_time")
75
+	enddate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endtime)
76
+	enddateunix := enddate.Unix()
77
+	scheduledate, _ := this.GetInt64("schedule_date")
78
+	zoneid, _ := this.GetInt64("zone_id")
79
+	patientid, _ := this.GetInt64("patient_id")
80
+	modeid, _ := this.GetInt64("mode_id")
81
+	scheduletype, _ := this.GetInt64("schedule_type")
82
+
83
+	//查询病人信息
84
+	patients, _ := service.GetPatientInfoMation(patientid)
85
+	var con = ""
86
+	if patients.IsInfectious == 0 {
87
+		con = ""
88
+	}
89
+	if patients.IsInfectious == 1 {
90
+		con = "无"
91
+	}
92
+	if patients.IsInfectious == 2 {
93
+		con = "有"
94
+	}
95
+	//查询病人上机信息
96
+	order, _ := service.GetPatientOrderInfo(scheduledate, patientid, orgid)
97
+	//查询病人今日透后评估数据
98
+	dislysis, _ := service.GetAssessmentAfterDissDataTwo(patientid, orgid, scheduledate)
99
+	fmt.Println("透析减少", dislysis.WeightLoss)
100
+	//			//根据床位号获取设备id
101
+	addmacher, _ := service.GetEquimentIDTwo(bedid, orgid)
102
+	unitype, _ := strconv.ParseInt(addmacher.UnitType, 10, 64)
103
+	fmt.Println(unitype)
104
+	plan, errplan := service.GetDisinfectionTwo(unitype, scheduletype, orgid)
105
+	//counts, errplan := service.GetUserTotalCount(orgid, bedid)
106
+	//var usertoal  int64
107
+	//fmt.Println(usertoal)
108
+	//for index, count := range counts {
109
+	//   if(index == 0){
110
+	//      usertoal = count.Total
111
+	//   }
112
+	//}
113
+	//usertotalint, errplan := strconv.ParseInt(addmacher.UserTotal, 10, 64)
114
+	//var total = usertoal + usertotalint
115
+	//totals := strconv.FormatInt(total, 10)
116
+	if errplan == gorm.ErrRecordNotFound {
117
+		returnData := make(map[string]interface{}, 0)
118
+		returnData["msstatus"] = "2"
119
+		this.ServeSuccessJSON(returnData)
120
+		return
121
+	} else {
122
+		_, errcode := service.GetInforTwo(patientid, scheduledate, orgid, scheduletype)
123
+		if errcode == gorm.ErrRecordNotFound {
124
+			information := models.DeviceInformation{
125
+				Date:                  scheduledate,
126
+				Zone:                  zoneid,
127
+				Class:                 scheduletype,
128
+				BedNumber:             bedid,
129
+				PatientId:             patientid,
130
+				DialysisMode:          modeid,
131
+				LongTime:              strconv.FormatInt(disinfectime, 10),
132
+				Disinfection:          1,
133
+				DialysisConcentration: 1,
134
+				DisinfectionStatus:    1,
135
+				Move:                  1,
136
+				UserOrgId:             orgid,
137
+				DisinfectType:         plan.Way,
138
+				DisinfectantType:      plan.MachineDisinfectant,
139
+				FluidPath:             plan.DisinfectanWay, //液路消毒方式
140
+				Disinfectant:          plan.Disinfectant,
141
+				Ctime:                 time.Now().Unix(),
142
+				Status:                1,
143
+				SignName:              order.FinishNurse,
144
+				EquimentId:            addmacher.ID,
145
+				DisinfectionResidue:   2,
146
+				Bed:                   addmacher.BedNumber,
147
+				StartTime:             order.StartTime,
148
+				EndTime:               order.EndTime,
149
+				Contagion:             con,
150
+				WeightLoss:            dislysis.WeightLoss,
151
+				Hyperfiltratio:        dislysis.ActualUltrafiltration,
152
+				DialysisHour:          strconv.FormatInt(dislysis.ActualTreatmentHour, 10),
153
+				MachineRun:            1,
154
+				DisinfecStartime:      startdateunix,
155
+				DisinfecEndtime:       enddateunix,
156
+			}
157
+			err := service.CreateInformationTwo(&information)
158
+			fmt.Println("报错", err)
159
+			if err != nil {
160
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
161
+				return
162
+			}
163
+			this.ServeSuccessJSON(map[string]interface{}{
164
+				"information": information,
165
+			})
166
+		} else if errcode == nil {
167
+
168
+			returnData := make(map[string]interface{}, 0)
169
+			returnData["msstatus"] = "1"
170
+			this.ServeSuccessJSON(returnData)
171
+			return
172
+		} else {
173
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
174
+			return
175
+		}
176
+	}
177
+}

+ 10 - 0
controllers/new_mobile_api_controllers/new_manage_api_router.go View File

@@ -0,0 +1,10 @@
1
+package new_mobile_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+func NewManageApiControllersRegisterRouters() {
6
+
7
+	beego.Router("m/api/getequitautoinfo", &NewManageApiController{}, "Get:GetEquitAutoInfo")
8
+	beego.Router("m/api/getdisinfection", &NewManageApiController{}, "Get:GetDisInfectionTime")
9
+	beego.Router("/m/api/savedisinfectioninfo", &NewManageApiController{}, "Get:SaveDisInfectionInfo")
10
+}

+ 1 - 0
routers/router.go View File

@@ -59,6 +59,7 @@ func init() {
59 59
 	//admin_api.AdminAPIControllersRegisterRouters()
60 60
 	new_m_api.CommonApiControllersRegisterRouters()
61 61
 	new_m_api.NewCommonApiControllersRegisterRouters()
62
+	new_m_api.NewManageApiControllersRegisterRouters()
62 63
 	controllers.ManageRouters()
63 64
 	//controllers.PatientRouters()
64 65
 }