Ver código fonte

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

XMLWAN 1 ano atrás
pai
commit
989aed1efb

+ 69 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Ver arquivo

@@ -259,6 +259,75 @@ func (this *StaffScheduleApiController) GetAllZone() {
259 259
 	})
260 260
 }
261 261
 
262
+func (this *StaffScheduleApiController) GetAllZonePb() {
263
+	orgid := this.GetMobileAdminUserInfo().Org.Id
264
+	timeLayout := "2006-01-02"
265
+	loc, _ := time.LoadLocation("Local")
266
+	start_time := this.GetString("start_time")
267
+	var startTime int64
268
+	if len(start_time) > 0 {
269
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
270
+		if err != nil {
271
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
272
+			return
273
+		}
274
+		startTime = theTime.Unix()
275
+	}
276
+	zoneid, _ := this.GetInt64("zoneid")
277
+	classtype, _ := this.GetInt64("classtype")
278
+
279
+	// is_open, _ := this.GetInt64("is_open")
280
+
281
+	
282
+	//获取空床位的排班数据
283
+	list, _ := service.GetPatientScheduleByPd(startTime, zoneid, orgid, classtype)
284
+	if len(list) > 0 {
285
+		for _, item := range list {
286
+			for _, device := range item.DeviceNumber {
287
+				item.TotalBed += 1
288
+				for _, schedule := range device.Schedule {
289
+					if schedule.ScheduleType == 1 {
290
+						item.SwBed += 1
291
+					}
292
+					if schedule.ScheduleType == 2 {
293
+						item.XwBed += 1
294
+					}
295
+					if schedule.ScheduleType == 3 {
296
+						item.WsBed += 1
297
+					}
298
+				}
299
+			}
300
+		}
301
+	}
302
+
303
+	// stockType, _ := service.GetStockType(orgid)
304
+	// zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
305
+	// if err != nil {
306
+	// 	this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
307
+	// 	return
308
+	// }
309
+	this.ServeSuccessJSON(map[string]interface{}{
310
+		"schedule":  list,
311
+		// "stockType": stockType,
312
+		// "zonelist":  zonelist,
313
+	})
314
+	
315
+
316
+
317
+
318
+	// id := this.GetMobileAdminUserInfo().Org.Id
319
+	// zone, err := service.GetAllMobileZonePb(id)
320
+
321
+	// if err != nil {
322
+	// 	this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
323
+	// 	return
324
+	// }
325
+	// this.ServeSuccessJSON(map[string]interface{}{
326
+	// 	"zone": zone,
327
+	// })
328
+}
329
+
330
+
262 331
 func (this *StaffScheduleApiController) GetPatientScheduleList() {
263 332
 	orgid := this.GetMobileAdminUserInfo().Org.Id
264 333
 	fmt.Println("orgid", orgid)

+ 1 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Ver arquivo

@@ -16,6 +16,7 @@ func StaffScheduleApiControllersRegisterRouters() {
16 16
 	beego.Router("/m/api/tosearchmobiletotal", &StaffScheduleApiController{}, "Get:ToSearchMobileTotal")
17 17
 	beego.Router("/m/api/changemobileoption", &StaffScheduleApiController{}, "Get:ChangeMobileOption")
18 18
 	beego.Router("/m/api/getallzone", &StaffScheduleApiController{}, "Get:GetAllZone")
19
+	beego.Router("/m/api/getallzonepb", &StaffScheduleApiController{}, "Get:GetAllZonePb")
19 20
 	beego.Router("/m/api/getpatientschedulelist", &StaffScheduleApiController{}, "Get:GetPatientScheduleList")
20 21
 	beego.Router("/m/api/deleteSchedule", &StaffScheduleApiController{}, "Get:DeleteSchedule")
21 22
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")

+ 36 - 0
service/doctor_schedule_service.go Ver arquivo

@@ -588,6 +588,42 @@ func GetAllMobileZone(orgid int64) (zone []*models.DeviceZone, err error) {
588 588
 	return zone, err
589 589
 }
590 590
 
591
+func GetAllMobileZonePb(orgid int64) (zone []*models.DeviceZonePb, err error) {
592
+
593
+	err = XTReadDB().Model(&zone).Preload("DeviceNumber", "status =1").Where("org_id = ? and status = 1", orgid).Find(&zone).Error
594
+	return zone, err
595
+}
596
+
597
+func GetPatientScheduleByPd(schedule_date int64, zoneid int64, orgid int64, class_type int64) (list []*models.DeviceZonePb, err error) {
598
+
599
+	db := XTReadDB().Table("xt_device_zone as x").Where("x.status = 1")
600
+	if zoneid > 0 {
601
+		db = db.Where("x.id = ?", zoneid)
602
+	}
603
+	if orgid > 0 {
604
+		db = db.Where("x.org_id = ?", orgid)
605
+	}
606
+	if class_type > 0 {
607
+		err = db.Select("x.id,x.org_id,x.name,x.type,x.sort").Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
608
+			return XTReadDB().Model(&models.DeviceNumber{}).Where("status = 1").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
609
+				return XTReadDB().Model(&models.BlodSchedule{}).Where("status = 1 AND user_org_id = ? and schedule_date = ? and schedule_type = ?", orgid, schedule_date, class_type).Preload("VmBloodPatients", "status = 1 and user_org_id = ?", orgid).Preload("BloodDialysisOrder", "status = 1 and dialysis_date = ?", schedule_date).Preload("BloodDialysisPrescription", "status = 1 and record_date = ?", schedule_date).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
610
+					return db.Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time asc")
611
+				})
612
+			})
613
+		}).Find(&list).Error
614
+	} else {
615
+		err = db.Select("x.id,x.org_id,x.name,x.type,x.sort").Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
616
+			return XTReadDB().Model(&models.DeviceNumber{}).Where("status = 1").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
617
+				return XTReadDB().Model(&models.BlodSchedule{}).Where("status = 1 AND user_org_id = ? and schedule_date = ?", orgid, schedule_date).Preload("VmBloodPatients", "status = 1 and user_org_id = ?", orgid).Preload("BloodDialysisOrder", "status = 1 and dialysis_date = ?", schedule_date).Preload("BloodDialysisPrescription", "status = 1 and record_date = ?", schedule_date).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
618
+					return db.Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("created_time asc")
619
+				})
620
+			})
621
+		}).Find(&list).Error
622
+	}
623
+
624
+	return list, err
625
+}
626
+
591 627
 func GetPatientSchedule(startime int64, zoneid int64, classtype int64, orgid int64) (schedule []*models.ScheduleTwenty, err error) {
592 628
 
593 629
 	db := XTReadDB().Table("xt_schedule as s")