浏览代码

更新数据

XMLWAN 4 年前
父节点
当前提交
bff1393ad4

+ 126 - 11
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go 查看文件

@@ -1739,8 +1739,8 @@ func (this *NewDialysisApiController) SaveBirthday() {
1739 1739
 
1740 1740
 func (this *NewDialysisApiController) GetOrgName() {
1741 1741
 
1742
-	orgid := this.GetMobileAdminUserInfo().Org.Id
1743
-	name, err := service.GetOrgName(orgid)
1742
+	id, _ := this.GetInt64("id")
1743
+	name, err := service.GetOrgName(id)
1744 1744
 	if err != nil {
1745 1745
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1746 1746
 		return
@@ -1938,12 +1938,29 @@ func (this *NewDialysisApiController) GetAllNumber() {
1938 1938
 func (this *NewDialysisApiController) DeleteBed() {
1939 1939
 	id, _ := this.GetInt64("id")
1940 1940
 	fmt.Println("id", id)
1941
-	err := service.DeleteBed(id)
1942
-	fmt.Println("删除失败", err)
1943
-	returnData := make(map[string]interface{}, 0)
1944
-	returnData["msg"] = "删除失败"
1945
-	this.ServeSuccessJSON(returnData)
1946
-	return
1941
+	nowDateTime := time.Now()
1942
+	nowDate := nowDateTime.Format("2006-01-02")
1943
+	nowDate += " 00:00:00"
1944
+	timeLayout := "2006-01-02"
1945
+	loc, _ := time.LoadLocation("Local")
1946
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
1947
+	fmt.Println(theTime.Unix())
1948
+	adminInfo := this.GetMobileAdminUserInfo()
1949
+	orgid := adminInfo.Org.Id
1950
+	_, errcode := service.GetSchedu(id, theTime.Unix(), orgid)
1951
+	fmt.Println("errcode ----------------", errcode)
1952
+	if errcode == gorm.ErrRecordNotFound {
1953
+		err := service.DeleteBed(id)
1954
+		fmt.Println("删除失败", err)
1955
+		returnData := make(map[string]interface{}, 0)
1956
+		returnData["msg"] = "删除失败"
1957
+		this.ServeSuccessJSON(returnData)
1958
+		return
1959
+	} else if errcode == nil {
1960
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1961
+		return
1962
+	}
1963
+
1947 1964
 }
1948 1965
 
1949 1966
 func (this *NewDialysisApiController) LoginOut() {
@@ -2036,9 +2053,7 @@ func (this *NewDialysisApiController) GetMyOrganazition() {
2036 2053
 }
2037 2054
 
2038 2055
 func (this *NewDialysisApiController) GetOrgInformation() {
2039
-
2040
-	adminUser := this.GetMobileAdminUserInfo()
2041
-	id := adminUser.Org.Id
2056
+	id, _ := this.GetInt64("id")
2042 2057
 	information, err := service.GetOrgInformation(id)
2043 2058
 	name, err := service.GetShortName(information.OrgType)
2044 2059
 	typeName, err := service.GetTypeName(name.Pid)
@@ -2158,3 +2173,103 @@ func (this *NewDialysisApiController) GetMyInforName() {
2158 2173
 		"Username": Username,
2159 2174
 	})
2160 2175
 }
2176
+
2177
+func (this *NewDialysisApiController) GetPartionDetail() {
2178
+	id, _ := this.GetInt64("id")
2179
+	partionDetail, err := service.GetPartionDetail(id)
2180
+	if err != nil {
2181
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2182
+		return
2183
+	}
2184
+	this.ServeSuccessJSON(map[string]interface{}{
2185
+		"partionDetail": partionDetail,
2186
+	})
2187
+}
2188
+
2189
+func (this *NewDialysisApiController) UpdatePartition() {
2190
+	id, _ := this.GetInt64("id")
2191
+	name := this.GetString("name")
2192
+	zoneType, _ := this.GetInt64("type")
2193
+	strInt64 := strconv.FormatInt(zoneType, 10)
2194
+	typeid, _ := strconv.Atoi(strInt64)
2195
+	zone := models.DeviceZone{
2196
+		Name: name,
2197
+		Type: typeid,
2198
+	}
2199
+	err := service.UpdatePartition(id, &zone)
2200
+	if err != nil {
2201
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2202
+		return
2203
+	}
2204
+	this.ServeSuccessJSON(map[string]interface{}{
2205
+		"zone": zone,
2206
+	})
2207
+}
2208
+
2209
+func (this *NewDialysisApiController) GetGroupDetail() {
2210
+	id, _ := this.GetInt64("id")
2211
+	groupDetail, err := service.GetGroupDetail(id)
2212
+	if err != nil {
2213
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2214
+		return
2215
+	}
2216
+	this.ServeSuccessJSON(map[string]interface{}{
2217
+		"groupDetail": groupDetail,
2218
+	})
2219
+
2220
+}
2221
+
2222
+func (this *NewDialysisApiController) UpdateGroup() {
2223
+	id, _ := this.GetInt64("id")
2224
+	name := this.GetString("name")
2225
+	group := models.DeviceGroup{Name: name}
2226
+	err := service.UpdateGroup(id, &group)
2227
+	if err != nil {
2228
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2229
+		return
2230
+	}
2231
+	this.ServeSuccessJSON(map[string]interface{}{
2232
+		"group": group,
2233
+	})
2234
+}
2235
+
2236
+func (this *NewDialysisApiController) GetBedDetail() {
2237
+	adminUser := this.GetMobileAdminUserInfo()
2238
+	orgid := adminUser.Org.Id
2239
+	id, _ := this.GetInt64("id")
2240
+	zone, _ := service.GetAllZoneOne(orgid)
2241
+	group, err := service.GetAllGroupOne(orgid)
2242
+	bedDetail, err := service.GetBedDetail(id)
2243
+	if err != nil {
2244
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2245
+		return
2246
+	}
2247
+	this.ServeSuccessJSON(map[string]interface{}{
2248
+		"zone":      zone,
2249
+		"group":     group,
2250
+		"bedDetail": bedDetail,
2251
+	})
2252
+}
2253
+
2254
+func (this *NewDialysisApiController) UpdatedBed() {
2255
+	id, _ := this.GetInt64("id")
2256
+	name := this.GetString("name")
2257
+	fmt.Println("name", name)
2258
+	zone, _ := this.GetInt64("zone")
2259
+	fmt.Println("zone", zone)
2260
+	group, _ := this.GetInt64("group")
2261
+	fmt.Println("group", group)
2262
+	number := models.DeviceNumber{
2263
+		Number:  name,
2264
+		ZoneID:  zone,
2265
+		GroupID: group,
2266
+	}
2267
+	err := service.UpdatedBed(id, &number)
2268
+	if err != nil {
2269
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2270
+		return
2271
+	}
2272
+	this.ServeSuccessJSON(map[string]interface{}{
2273
+		"number": number,
2274
+	})
2275
+}

+ 6 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go 查看文件

@@ -135,4 +135,10 @@ func NewMobileAPIControllersRegisterRouters() {
135 135
 	beego.Router("/m/api/patient/getallorgtype", &NewDialysisApiController{}, "Get:GetAllOrgType")
136 136
 	beego.Router("/m/api/patient/editorg", &NewDialysisApiController{}, "Get:EditOrg")
137 137
 	beego.Router("/m/api/patient/getmyinforname", &NewDialysisApiController{}, "Get:GetMyInforName")
138
+	beego.Router("/m/api/patient/getpartiondetail", &NewDialysisApiController{}, "Get:GetPartionDetail")
139
+	beego.Router("/m/api/patient/updatepartition", &NewDialysisApiController{}, "Get:UpdatePartition")
140
+	beego.Router("/m/api/patient/getgroupdetail", &NewDialysisApiController{}, "Get:GetGroupDetail")
141
+	beego.Router("/m/api/patient/updategroup", &NewDialysisApiController{}, "Get:UpdateGroup")
142
+	beego.Router("/m/api/patient/getbeddetail", &NewDialysisApiController{}, "Get:GetBedDetail")
143
+	beego.Router("/m/api/patient/updatebed", &NewDialysisApiController{}, "Get:UpdatedBed")
138 144
 }

+ 53 - 3
service/patientmanage_service.go 查看文件

@@ -526,8 +526,8 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
526 526
 		db = db.Where("start_time<=?", end)
527 527
 	}
528 528
 	offset := (page - 1) * limit
529
-	err = db.Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("start_time desc").Scan(&doctoradvice).Error
530
-	fmt.Print("错误是什么东西", err)
529
+	err = db.Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("x.start_time desc").Scan(&doctoradvice).Error
530
+	fmt.Print("错误是什么", err)
531 531
 	return
532 532
 }
533 533
 
@@ -900,7 +900,7 @@ func DeleteChild(id int64) error {
900 900
 
901 901
 func DeletePatient(id int64) error {
902 902
 
903
-	err = XTWriteDB().Model(models.DoctorAdvice{}).Where("id=? and parent_id = ?", id, id).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
903
+	err = XTWriteDB().Model(models.DoctorAdvice{}).Where("id=? or parent_id = ?", id, id).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
904 904
 	return err
905 905
 }
906 906
 
@@ -1118,6 +1118,19 @@ func GetAllNumber(page int64, limit int64, orgid int64) (number []*models.Device
1118 1118
 	return number, total, err
1119 1119
 }
1120 1120
 
1121
+func GetSchedu(bedid int64, thetime int64, orgid int64) (*models.XtSchedule, error) {
1122
+	schedule := models.XtSchedule{}
1123
+	err := XTReadDB().Model(&schedule).Where("bed_id = ? and schedule_date = ? and user_org_id = ? and status = 1", bedid, thetime, orgid).Find(&schedule).Error
1124
+	if err == gorm.ErrRecordNotFound {
1125
+		return nil, err
1126
+	}
1127
+	if err != nil {
1128
+		return nil, err
1129
+	}
1130
+	return &schedule, nil
1131
+
1132
+}
1133
+
1121 1134
 func DeleteBed(id int64) error {
1122 1135
 	err := XTWriteDB().Model(models.DeviceNumber{}).Where("id=?", id).Update(map[string]interface{}{"status": 0, "ctime": time.Now().Unix()}).Error
1123 1136
 	return err
@@ -1214,3 +1227,40 @@ func GetAdminName(id int64) (models.AdminUser, error) {
1214 1227
 	err := UserReadDB().Model(&user).Where("id=? and status =1", id).Find(&user).Error
1215 1228
 	return user, err
1216 1229
 }
1230
+
1231
+func GetPartionDetail(id int64) (models.DeviceZone, error) {
1232
+
1233
+	zone := models.DeviceZone{}
1234
+	err := XTReadDB().Model(&zone).Where("id=? and status = 1", id).Find(&zone).Error
1235
+	return zone, err
1236
+}
1237
+
1238
+func UpdatePartition(id int64, zone *models.DeviceZone) error {
1239
+
1240
+	err := XTWriteDB().Model(&zone).Where("id=?", id).Update(map[string]interface{}{"name": zone.Name, "type": zone.Type, "mtime": time.Now().Unix()}).Error
1241
+	return err
1242
+}
1243
+
1244
+func GetGroupDetail(id int64) (models.DeviceGroup, error) {
1245
+	group := models.DeviceGroup{}
1246
+	err := XTReadDB().Model(&group).Where("id=? and status = 1", id).Find(&group).Error
1247
+	return group, err
1248
+}
1249
+
1250
+func UpdateGroup(id int64, group *models.DeviceGroup) error {
1251
+
1252
+	err := XTWriteDB().Model(&group).Where("id=?", id).Update(map[string]interface{}{"name": group.Name, "mtime": time.Now().Unix()}).Error
1253
+	return err
1254
+}
1255
+
1256
+func GetBedDetail(id int64) (models.DeviceNumber, error) {
1257
+	number := models.DeviceNumber{}
1258
+	err := XTReadDB().Model(&number).Where("id=? and status =1", id).Find(&number).Error
1259
+	return number, err
1260
+}
1261
+
1262
+func UpdatedBed(id int64, number *models.DeviceNumber) error {
1263
+
1264
+	err = XTWriteDB().Model(&number).Where("id=?", id).Update(map[string]interface{}{"number": number.Number, "zone_id": number.ZoneID, "group_id": number.GroupID, "mtime": time.Now().Unix()}).Error
1265
+	return err
1266
+}