Browse Source

提交代码

陈少旭 9 months ago
parent
commit
aa8c48d3a2
3 changed files with 30 additions and 14 deletions
  1. 11 2
      controllers/statistics_api_controller.go
  2. 9 0
      models/dialysis.go
  3. 10 12
      service/statistis_qc_service.go

+ 11 - 2
controllers/statistics_api_controller.go View File

@@ -1177,8 +1177,17 @@ func (c *StatisticsApiController) GetDialysisTotalDetailInfo() {
1177 1177
 	origin, _ := c.GetInt64("origin")
1178 1178
 	page, _ := c.GetInt64("page")
1179 1179
 	limit, _ := c.GetInt64("limit")
1180
-	start_date := strings.Split(date_str, "~")[0]
1181
-	end_date := strings.Split(date_str, "~")[1]
1180
+	time_way, _ := c.GetInt64("time_way")
1181
+	var start_date string
1182
+	var end_date string
1183
+	if time_way == 2 {
1184
+		start_date = date_str
1185
+		end_date = date_str
1186
+	} else {
1187
+		start_date = strings.Split(date_str, "~")[0]
1188
+		end_date = strings.Split(date_str, "~")[1]
1189
+	}
1190
+
1182 1191
 	if origin == 1 {
1183 1192
 		qcp, total, _ := service.GetDialysisPrescriptionInfo(start_date, end_date, mode, c.GetAdminUserInfo().CurrentOrgId, page, limit)
1184 1193
 		c.ServeSuccessJSON(map[string]interface{}{

+ 9 - 0
models/dialysis.go View File

@@ -1662,3 +1662,12 @@ type XtDialysisOrderLost struct {
1662 1662
 func (XtDialysisOrderLost) TableName() string {
1663 1663
 	return "xt_dialysis_order"
1664 1664
 }
1665
+
1666
+type MewTreatmentMode struct {
1667
+	Name   string `gorm:"column:name" json:"name" form:"name"`
1668
+	ModeID int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1669
+}
1670
+
1671
+func (MewTreatmentMode) TableName() string {
1672
+	return "xt_treatment_mode"
1673
+}

+ 10 - 12
service/statistis_qc_service.go View File

@@ -50,12 +50,10 @@ type DialysisStat struct {
50 50
 	Total  int            `json:"合计"`
51 51
 }
52 52
 
53
-func GetTreatmentModes() ([]models.TreatmentMode, error) {
54
-	var modes []models.TreatmentMode
55
-	if err := XTReadDB().Model(&models.TreatmentMode{}).Find(&modes).Error; err != nil {
56
-		return nil, err
57
-	}
58
-	return modes, nil
53
+func GetTreatmentModes(org_id int64, start string, end string) (mode []models.MewTreatmentMode) {
54
+	//XTReadDB().Model(&models.HisPrescription{}).Joins("join xt_treatment_mode mode on").Where("user_org_id = ?", org_id).Find(&modes).Error
55
+	XTReadDB().Table("xt_dialysis_prescription p").Joins("join xt_treatment_mode mode on mode.id = p.mode_id").Where("p.user_org_id = ? and  FROM_UNIXTIME(p.record_date) >= ? AND FROM_UNIXTIME(p.record_date) <= ?", org_id, start, end).Select("mode.name as name, p.mode_id as mode_id").Group("p.mode_id").Scan(&mode)
56
+	return
59 57
 }
60 58
 
61 59
 func GetDialysisStats(start int64, end int64, mode int64, org_id int64, time_way int64) ([]map[string]interface{}, error) {
@@ -72,13 +70,13 @@ func GetDialysisStats(start int64, end int64, mode int64, org_id int64, time_way
72 70
 	// 将时间格式化为字符串
73 71
 	endDate := t2.Format(layout) + " 00:00:00"
74 72
 	//var stats []DialysisStat
75
-	var modes []models.TreatmentMode
73
+	var modes []models.MewTreatmentMode
76 74
 	fmt.Println(mode)
77 75
 	if mode == 0 {
78
-		modes, _ = GetTreatmentModes()
76
+		modes = GetTreatmentModes(org_id, startDate, endDate)
79 77
 
80 78
 	} else {
81
-		modes_two, _ := GetTreatmentModes()
79
+		modes_two := GetTreatmentModes(org_id, startDate, endDate)
82 80
 		for _, item := range modes_two {
83 81
 			if item.ModeID == mode {
84 82
 				modes = append(modes, item)
@@ -218,13 +216,13 @@ func GetScheduleStats(start int64, end int64, mode int64, org_id int64, time_way
218 216
 	// 将时间格式化为字符串
219 217
 	endDate := t2.Format(layout) + " 00:00:00"
220 218
 	//var stats []DialysisStat
221
-	var modes []models.TreatmentMode
219
+	var modes []models.MewTreatmentMode
222 220
 	fmt.Println(mode)
223 221
 	if mode == 0 {
224
-		modes, _ = GetTreatmentModes()
222
+		modes = GetTreatmentModes(org_id, startDate, endDate)
225 223
 
226 224
 	} else {
227
-		modes_two, _ := GetTreatmentModes()
225
+		modes_two := GetTreatmentModes(org_id, startDate, endDate)
228 226
 		for _, item := range modes_two {
229 227
 			if item.ModeID == mode {
230 228
 				modes = append(modes, item)