Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
c92ebdc08b
3 changed files with 21 additions and 13 deletions
  1. 13 12
      models/device_models.go
  2. 1 0
      models/schedule_models.go
  3. 7 1
      service/schedule_service.go

+ 13 - 12
models/device_models.go View File

@@ -393,18 +393,19 @@ type Schedules struct {
393 393
 }
394 394
 
395 395
 type XtSchedule struct {
396
-	ID           int64 `gorm:"column:id" json:"id" form:"id"`
397
-	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
398
-	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
399
-	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
400
-	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
401
-	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
402
-	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
403
-	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
404
-	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
405
-	Status       int64 `gorm:"column:status" json:"status" form:"status"`
406
-	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
407
-	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
396
+	ID              int64                   `gorm:"column:id" json:"id" form:"id"`
397
+	UserOrgId       int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
398
+	PartitionId     int64                   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
399
+	BedId           int64                   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
400
+	PatientId       int64                   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
401
+	ScheduleDate    int64                   `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
402
+	ScheduleType    int64                   `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
403
+	ScheduleWeek    int64                   `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
404
+	ModeId          int64                   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
405
+	Status          int64                   `gorm:"column:status" json:"status" form:"status"`
406
+	CreatedTime     int64                   `gorm:"column:created_time" json:"created_time" form:"created_time"`
407
+	UpdatedTime     int64                   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
408
+	LastAfterWeight AssessmentAfterDislysis `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
408 409
 }
409 410
 
410 411
 func (XtSchedule) TableName() string {

+ 1 - 0
models/schedule_models.go View File

@@ -197,6 +197,7 @@ type VmSchedulesRemind struct {
197 197
 	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
198 198
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId;"`
199 199
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
200
+	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
200 201
 }
201 202
 
202 203
 func (VmSchedulesRemind) TableName() string {

+ 7 - 1
service/schedule_service.go View File

@@ -609,6 +609,8 @@ func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType in
609 609
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
610 610
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date =?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
611 611
 		return db.Where("status =1").Order("id asc")
612
+	}).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
613
+		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, scheduleDate)
612 614
 	}).Find(&list).Error
613 615
 
614 616
 	return list, err
@@ -634,6 +636,8 @@ func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int
634 636
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
635 637
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
636 638
 		return db.Where("status =1").Order("id asc")
639
+	}).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
640
+		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, scheduleDate)
637 641
 	}).Find(&list).Error
638 642
 
639 643
 	return list, err
@@ -987,6 +991,8 @@ func GetDataPrint(orgid int64) (models.XtDataPrint, error) {
987 991
 
988 992
 func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*models.XtSchedule, err error) {
989 993
 
990
-	err = XTReadDB().Model(&schedule).Where("schedule_date >=? and schedule_date<=? and status = 1 and user_org_id = ?", startime, endtime, orgid).Find(&schedule).Error
994
+	err = XTReadDB().Model(&schedule).Where("schedule_date >=? and schedule_date<=? and status = 1 and user_org_id = ?", startime, endtime, orgid).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
995
+		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, endtime)
996
+	}).Find(&schedule).Error
991 997
 	return schedule, err
992 998
 }