Browse Source

体积小

XMLWAN 3 years ago
parent
commit
7c6104f201

+ 31 - 0
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

@@ -56,6 +56,9 @@ func XcxApiControllersRegisterRouters() {
56 56
 	//获取数据字典数据
57 57
 	beego.Router("/xcx/api/mobile/getdataconfig", &XcxApiController{}, "Get:GetDataConfig")
58 58
 
59
+	//检验检查
60
+	beego.Router("/xcx/api/mobile/getinspectionlist", &XcxApiController{}, "Get:GetInspectionList")
61
+
59 62
 }
60 63
 
61 64
 type XcxApiController struct {
@@ -854,3 +857,31 @@ func (this *XcxApiController) GetDataConfig() {
854 857
 		"list": configList,
855 858
 	})
856 859
 }
860
+
861
+func (this *XcxApiController) GetInspectionList() {
862
+
863
+	start_time := this.GetString("start_time")
864
+	end_time := this.GetString("end_time")
865
+	patient_id, _ := this.GetInt64("patient_id")
866
+	fmt.Println("patient_id", patient_id)
867
+	timeLayout := "2006-01-02"
868
+	loc, _ := time.LoadLocation("Local")
869
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
870
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
871
+
872
+	list, _ := service.GetInspectionGroupList(patient_id, startTime.Unix(), endTime.Unix())
873
+
874
+	insepctionList, _ := service.GetInsepctionList(patient_id, startTime.Unix(), endTime.Unix())
875
+
876
+	for _, item := range list {
877
+		for _, it := range insepctionList {
878
+			if item.ProjectId == it.ProjectId && item.InspectDate == it.InspectDate {
879
+				item.Childs = append(item.Childs, it)
880
+			}
881
+		}
882
+	}
883
+
884
+	this.ServeSuccessJSON(map[string]interface{}{
885
+		"list": list,
886
+	})
887
+}

+ 22 - 0
models/xcx_user_models.go View File

@@ -560,3 +560,25 @@ type XcxSchedule struct {
560 560
 func (XcxSchedule) TableName() string {
561 561
 	return "xt_schedule"
562 562
 }
563
+
564
+type XcxInspection struct {
565
+	ID           int64            `gorm:"column:id" json:"id" form:"id"`
566
+	PatientId    int64            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
567
+	OrgId        int64            `gorm:"column:org_id" json:"org_id" form:"org_id"`
568
+	ProjectId    int64            `gorm:"column:project_id" json:"project_id" form:"project_id"`
569
+	ItemId       int64            `gorm:"column:item_id" json:"item_id" form:"item_id"`
570
+	ItemName     string           `gorm:"column:item_name" json:"item_name" form:"item_name"`
571
+	ProjectName  string           `gorm:"column:project_name" json:"project_name" form:"project_name"`
572
+	InspectType  int64            `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
573
+	InspectValue string           `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
574
+	InspectTips  string           `gorm:"column:inspect_tips" json:"inspect_tips" form:"inspect_tips"`
575
+	InspectDate  int64            `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
576
+	Status       int64            `gorm:"column:status" json:"status" form:"status"`
577
+	CreatedTime  int64            `gorm:"column:created_time" json:"created_time" form:"created_time"`
578
+	UpdatedTime  int64            `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
579
+	Childs       []*XcxInspection `json:"childs" `
580
+}
581
+
582
+func (XcxInspection) TableName() string {
583
+	return "xt_inspection"
584
+}

+ 32 - 1
service/xcx_mobile_api_service.go View File

@@ -576,6 +576,37 @@ func GetDataConfig(orgid int64) (list []*models.XcxDataConfig, err error) {
576 576
 func GetLastScheduleListOne(patient_id int64, schedule_date int64) (models.XcxSchedule, error) {
577 577
 
578 578
 	schedule := models.XcxSchedule{}
579
-	err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date <=?", patient_id, schedule_date).Last(&schedule).Error
579
+	err := XTReadDB().Model(&schedule).Where("patient_id = ? and status = 1 and schedule_date <=?", patient_id, schedule_date).Order("schedule_date desc").Last(&schedule).Error
580 580
 	return schedule, err
581 581
 }
582
+
583
+func GetInspectionGroupList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
584
+
585
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
586
+	if patientid > 0 {
587
+		db = db.Where("x.patient_id = ?", patientid)
588
+	}
589
+	if startime > 0 {
590
+		db = db.Where("x.inspect_date >= ?", startime)
591
+	}
592
+	if endtime > 0 {
593
+		db = db.Where("x.inspect_date <= ?", endtime)
594
+	}
595
+	err = db.Group("x.inspect_date,x.project_id").Find(&inspection).Error
596
+	return inspection, err
597
+}
598
+
599
+func GetInsepctionList(patientid int64, startime int64, endtime int64) (inspection []*models.XcxInspection, err error) {
600
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
601
+	if patientid > 0 {
602
+		db = db.Where("x.patient_id = ?", patientid)
603
+	}
604
+	if startime > 0 {
605
+		db = db.Where("x.inspect_date >= ?", startime)
606
+	}
607
+	if endtime > 0 {
608
+		db = db.Where("x.inspect_date <= ?", endtime)
609
+	}
610
+	err = db.Find(&inspection).Error
611
+	return inspection, err
612
+}